I'm trying to create a form where a user can email selected files from a GridField, I had done something like this back in he day with a TableList Field, but I'm not sure how to augment teh gridfield witha column of checboxes, that the Submit action iterate through
Any guidance would be helpful
EDIT
I figured it out, I created the following GridField Componant:
class GridFieldSelectBox implements GridField_ColumnProvider {
public function __construct($useToggle = true, $targetFragment = 'before') {
$this->targetFragment = $targetFragment;
$this->useToggle = $useToggle;
}
public function augmentColumns($field, &$cols) {
if(!in_array('Select', $cols)) $cols[] = 'Select';
}
public function getColumnsHandled($field) {
return array('Select');
}
public function getColumnContent($field, $record, $col) {
if($record->canView()) {
$data = new ArrayData(array(
'ID' => $record->ID
));
return $data->renderWith('GridFieldSelectItem');
}
}
public function getColumnAttributes($field, $record, $col) {
return array('class' => 'col-select');
}
public function getColumnMetadata($gridField, $col) {
return array('title' => "Select");
}
}
and this template to render the checkbox
<input id="File_$ID" class="checkbox" name="AttachedFiles[]" type="checkbox" value="$ID" />
I then added to the gridfield on the front end and I can iterate throught $data["AttachedFiles"] on the form action