$name
$name : string
The name for this helper, used when you want to define a global custom callback for a given field
The header helper allows you to render the content of the header for a given field in a CSV table. When defining a custom callback for this helper, using the following callback parameters:
$csvCell->getHeaderRenderer()->assign( 'my_model:my_field', function ($helper, $field) { // Param $helper is a reference to this instance of the Header helper // Param $field is your Field object, so you can get the label, etc. return 'something'; } );
NOTE: You do not have to supply a callback for this helper for any fields. By default, this helper will just use the field's label for the header content, so you only need to supply a custom callback if the field label is not appropriate.
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
If no custom callback is defined for a field, it will fall back to this method to find a suitable callback. In the case of the Header helper, we fall back to all fields just returning their labels.
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 |
render(\Dewdrop\Fields\FieldInterface $field) : string
Render the header content for the supplied field.
\Dewdrop\Fields\FieldInterface | $field |
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 |