this looks fine to me. Just a lot of additional hooks – right?
True, but it has to be this way for the way we're doing things.
We added them all, it wasn't really a big deal.
When we release the next version, let us know if you have questions, otherwise:
All the new list hooks are under this form:
Code:
list_field_builder_type_{type}_subscriber_build_field_array
Where {type} can be any of the above you listed: url, textarea, number, etc.
All the new survey hooks are under this form:
Code:
survey_field_builder_type_{type}_responder_build_field_array
Where {type} can be any of the above you listed: url, textarea, number, etc.
Please beware that some field types, such as radiolist, checkboxlist, will make available more arguments for you to make use of, to give you an example, to alter the build array for a text field, we have this hook:
PHP:
return $hooks->applyFilters('survey_field_builder_type_text_responder_build_field_array', array(
'sort_order' => (int)$field->sort_order,
'field_html' => $fieldHtml,
), $model, $field);
So in our callback:
PHP:
Yii::app()->hooks->addFilter('survey_field_builder_type_text_responder_build_field_array', function($buildArray, $model, $field){
$viewFile = 'your-own-view-file';
// overwrite default html with yours.
$buildArray['field_html'] = $this->owner->renderInternal($viewFile, compact('model', 'field'), true)
return $buildArray;
});
MailWizz makes available 3 params, the $buildArray which you must return, and then additional info, like the $model and the $field.
However, for example, for the checkboxlist filter, the hook signature looks like:
PHP:
return Yii::app()->hooks->applyFilters('survey_field_builder_type_checkboxlist_responder_build_field_array', array(
'sort_order' => (int)$field->sort_order,
'field_html' => $fieldHtml,
), $models[0], $field, $values, $options, $models);
which means the callback will look like:
PHP:
Yii::app()->hooks->addFilter('survey_field_builder_type_checkboxlist_responder_build_field_array', function($buildArray, $model, $field, $values, $options, $models){
$viewFile = 'your-own-view-file';
// overwrite default html with yours.
$buildArray['field_html'] = $this->owner->renderInternal($viewFile, compact('model', 'field', 'values', 'options'), true)
return $buildArray;
});
Where, as you see, you have more arguments available for you.