$name
$name : string
The name for this helper, used when you want to define a global custom callback for a given field
The TdClassNames helper allows you to render a CSS class string that will be added to the <td> of your table cell. When defining a custom callback for this helper, using the following callback parameters:
$tableCell->getContentRenderer()->assign( 'my_model:my_field', function ($helper, array $rowData, $rowIndex, $columnIndex) { // Param $helper is a reference to this instance of the Header helper // Param $rowData if an associative array representing all the data available to render this table row. // Param $rowIndex is a zero-based index of the current row being rendered // Param $columnIndex is a zero-based index of the current column being rendered return '' . $helper->getView()->escapeHtml($row['my_field']) . '; } );
$view : \Dewdrop\View\View
A view object used for rendering and escaping.
assign(mixed $assignments, callable $callable = null) : \Dewdrop\Fields\Helper\HelperAbstract
Assign one more custom per-instance callbacks for this helper. If the $arguments param is an array, this method expects that the keys will be field IDs and the values will be callables, assigning custom callbacks for multiple fields in one call. If, however, $assignments is a string or a FieldInterface object, a single custom callback assignment will be made.
mixed | $assignments | |
callable | $callable |
getFieldAssignment(\Dewdrop\Fields\FieldInterface $field) : callable
Get the callback that will be used for the given FieldInterface object.
\Dewdrop\Fields\FieldInterface | $field |
detectCallableForField(\Dewdrop\Fields\FieldInterface $field) : callable
By default, we just return an empty string if there was not custom callback found for a field.
If no callback candidate is found, just return false from this method, which will be detected by getFieldAssignment(), causing execution to halt.
\Dewdrop\Fields\FieldInterface | $field |
__construct(\Dewdrop\View\View $view)
Provide a Dewdrop view for rendering.
\Dewdrop\View\View | $view |
getView() : \Dewdrop\View\View
Get the Dewdrop view object that can be used to render the cell's content and escape it to prevent XSS.
getEscaper() : \Dewdrop\View\View
The TableCell helpers originally used an Escaper rather than a Dewdrop view object. This was limiting and also error-prone because Escaper fails to handle nulls well. The view API has all of Escaper's public methods, though, so returning it here, should not break any code.
render(\Dewdrop\Fields\FieldInterface $field, array $rowData, integer $rowIndex, integer $columnIndex) : string
Render a CSS class string for the field's table cell. Your callback can return either a string or an array of classes.
\Dewdrop\Fields\FieldInterface | $field | |
array | $rowData | |
integer | $rowIndex | |
integer | $columnIndex |
None found |
wrapCallable(callable $callable, \Dewdrop\Fields\FieldInterface $field = null) : callable
Wrap a field's callback to ensure that a reference to the helper is always supplied as the first argument to the callback.
callable | $callable | |
\Dewdrop\Fields\FieldInterface | $field |
None found |