FormHelper: refactor option detection as a method #974

merged 0 commits into from Nov 28, 2012


None yet

2 participants

rchavik commented Nov 23, 2012

Allows easier way for subclasses to adjust $options

@markstory markstory and 1 other commented on an outdated diff Nov 24, 2012
+ * - `between` - Content to place between the label + input.
+ * - `format` - format template for element order. Any element that is not in the array, will not be in the output.
+ * - Default input format order: array('before', 'label', 'between', 'input', 'after', 'error')
+ * - Default checkbox format order: array('before', 'input', 'between', 'label', 'after', 'error')
+ * - Hidden input will not be formatted
+ * - Radio buttons cannot have the order of input and label elements controlled with these settings.
+ *
+ * @param string $fieldName This should be "Modelname.fieldname"
+ * @param array $options Each type of input takes different options.
+ * @return string Completed form widget.
+ * @link
+ */
+ public function input($fieldName, $options = array()) {
+ if (!isset($options['modelKey'])) {
+ $inputOptions = $this->_inputOptions($fieldName, $options);
+ extract($inputOptions);
markstory Nov 24, 2012 Member

Why is this only done when $options['modelKey'] is not set?

rchavik Nov 25, 2012 Member

the idea was to allow a subclass to skip it since it might want to call _inputOptions themselves, adjust $options, call parent::input().

any better way to achieve this?

markstory Nov 26, 2012 Member

Why not have a separate and specific option for disabling the automatic input options?

rchavik Nov 26, 2012 Member

yup. i thought of that too but wanted to avoid introducing a new option.
but i agree it's cleaner and less hacky.

I'll adjust the PR.


@rchavik rchavik merged commit 6670997 into cakephp:2.3 Nov 28, 2012

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment