public function __construct($options = null) { $this->_initializePrefixes(); $this->setDisposition(self::DISPOSITION_SEARCH); $renderButton = true; if (isset($options['renderInNavBar']) && true === $options['renderInNavBar']) { $this->_removeClassNames('form-search'); $classes = ['navbar-search']; if (isset($options['pullItRight']) && true === $options['pullItRight']) { $classes[] = 'pull-right'; unset($options['pull-right']); } $this->_addClassNames($classes); unset($options['renderInNavBar']); $renderButton = false; } // Add the search input $inputName = isset($options['inputName']) ? $options['inputName'] : 'searchQuery'; $placeholder = isset($options['placeholder']) ? $options['placeholder'] : null; $this->addElement('text', $inputName, ['class' => 'search-query', 'placeholder' => $placeholder]); if ($renderButton) { $buttonLabel = isset($options['submitLabel']) ? $options['submitLabel'] : 'Submit'; $this->addElement('submit', 'submit', ['class' => 'btn btn-default', 'label' => $buttonLabel]); } parent::__construct($options); }
private function tr($basePath, $data, $options = []) { if ($this->readonly) { $options['readonly'] = true; } $options = Hash::merge(Hash::merge($this->formOptions, $options), ['tftag' => 'td', 'tag' => 'tr', 'url' => Hash::extract($this->options, 'url')]); $form = new InlineForm($this->Html, $data, $this->model, $options); $is_first = true; return $form->create() . implode(array_map(function ($field) use($basePath, $form, &$is_first) { if ($is_first && !$this->readonly) { $button = '<button onclick="return false;" class="btn btn-danger btn-xs if-delete pull-right"><span class="glyphicon glyphicon-remove"></span></button>'; $is_first = false; } else { $button = ''; } $path = $field['path']; $spath = explode('.', $path); $options = $field['options']; $options['data-field'] = end($spath); return $this->Html->tag('td', $button . $form->control($path, $options)); }, $this->fields)) . $form->writePrimaryKey(['tag' => 'td']) . $form->end(); }