public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { if (preg_match('/<input [^>]*type="checkbox"/', $field)) { return parent::formatRow(preg_replace('/<label[^>]*>/', "\$0{$field}", $label), null, $errors, $help, $hiddenFields); } return parent::formatRow($label, $field, $errors, $help, $hiddenFields); }
public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { $originalRowFormat = $this->rowFormat; if (strpos($field, 'type="radio"') || strpos($field, 'type="checkbox"')) { $isCheckboxList = strpos($field, 'checkbox_list') !== false; $field = str_replace(array('<ul class="radio_list">', '<ul class="checkbox_list">', '</ul>', '<li>', '</li>'), array('', '', '', '', ''), $field); //change order of input and label tags $pattern = '#(<input\\b[^>]*/>)(.*?)(<label\\b[^>]*>)(.*?)(</label>)$#'; $replacement = '$3$4$5$1'; $rows = explode("\n", $field); foreach ($rows as $index => $row) { $rows[$index] = preg_replace($pattern, $replacement, $row); } $field = implode("\n", $rows); if ($isCheckboxList) { $label = substr($label, strpos($label, '>') + 1); $label = substr($label, 0, strpos($label, '<')); $field = '<fieldset data-role="controlgroup"><legend>' . $label . '</legend>' . $field . '</fieldset>'; $label = null; } else { $field = '<div data-role="controlgroup">' . $field . '</div>'; } } $row = parent::formatRow($label, $field, $errors, $help, $hiddenFields); $this->rowFormat = $originalRowFormat; $fieldName = substr($label, strpos($label, ' for="') + 6); $fieldName = substr($fieldName, 0, strpos($fieldName, '"')); return strtr($row, array('%row_class%' => count($errors) > 0 ? ' error' : '', '%fieldname%' => $fieldName, ' type="' => count($errors) > 0 ? ' class="error" type="' : ' type="')); }
public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { $row = parent::formatRow( $label, $field, $errors, $help, $hiddenFields ); return strtr($row, array( '%row_class%' => (count($errors) > 0) ? ' form_error' : '', )); }
/** * @see parent */ public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { $row = parent::formatRow($label, $field, $errors, $help, $hiddenFields); $rowClasses = array(); if (count($errors) > 0 && $this->rowErrorClass) { $rowClasses[] = $this->rowErrorClass; } if ($this->useLabelForAsClassesInFormRow) { // try match the field id and classes to add as a class to the row as a way // to target the field preg_match_all('/for=(\'|")([\\w]*)(\'|")/', $label, $matches, PREG_SET_ORDER); if ($matches) { foreach ($matches as $match) { $rowClasses[] = $match[2]; } } } return strtr($row, array('%row_class%' => count($rowClasses) ? ' ' . implode(', ', array_unique($rowClasses)) : '')); }
public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { return strtr(parent::formatRow($label, $field, $errors, $help, $hiddenFields), array('%is_error%' => count($errors) > 0 ? ' field_error' : '')); }
/** * Отрисовать поле формы * * Хак, чтобы поменять местами checkbox и label */ public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { if (strpos($field, 'checkbox') !== false) { return parent::formatRow($field, $label, $errors, $help, $hiddenFields); } return parent::formatRow($label, $field, $errors, $help, $hiddenFields); }