Changeset 5999
- Timestamp:
- 11/13/07 19:58:52 (1 year ago)
- Files:
-
- branches/dwhittle/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_filters.php (modified) (1 diff)
- branches/dwhittle/lib/plugins/sfPropelPlugin/test/functional/filterTest.php (modified) (2 diffs)
- branches/dwhittle/lib/widget/sfWidgetFormSchema.class.php (modified) (5 diffs)
- branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatter.class.php (modified) (4 diffs)
- branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatterList.class.php (modified) (1 diff)
- branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatterTable.class.php (modified) (1 diff)
- branches/dwhittle/test/unit/widget/sfWidgetFormSchemaFormatterListTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/widget/sfWidgetFormSchemaFormatterTableTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/widget/sfWidgetFormSchemaTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_filters.php
r5248 r5999 13 13 <?php endif; ?> 14 14 <div class="form-row"> 15 <label for=" <?php echo $column->getName() ?>">[?php echo __('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>:') ?]</label>15 <label for="filters_<?php echo $column->getName() ?>">[?php echo __('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>:') ?]</label> 16 16 <div class="content"> 17 17 [?php echo <?php echo $this->getColumnFilterTag($column) ?> ?] 18 18 <?php if ($this->getParameterValue('list.fields.'.$column->getName().'.filter_is_empty')): ?> 19 <div>[?php echo checkbox_tag('filters[<?php echo $column->getName() ?>_is_empty]', 1, isset($filters['<?php echo $column->getName() ?>_is_empty']) ? $filters['<?php echo $column->getName() ?>_is_empty'] : null) ?] <label for="filters [<?php echo $column->getName() ?>_is_empty]">[?php echo __('is empty') ?]</label></div>19 <div>[?php echo checkbox_tag('filters[<?php echo $column->getName() ?>_is_empty]', 1, isset($filters['<?php echo $column->getName() ?>_is_empty']) ? $filters['<?php echo $column->getName() ?>_is_empty'] : null) ?] <label for="filters_<?php echo $column->getName() ?>_is_empty">[?php echo __('is empty') ?]</label></div> 20 20 <?php endif; ?> 21 21 </div> branches/dwhittle/lib/plugins/sfPropelPlugin/test/functional/filterTest.php
r5125 r5999 24 24 $b-> 25 25 checkListCustomization('filters', array('filters' => array('title', 'body', 'online', 'category_id', 'created_at')))-> 26 checkResponseElement('div.sf_admin_filters label[for=" title"]', 'Title:')->26 checkResponseElement('div.sf_admin_filters label[for="filters_title"]', 'Title:')-> 27 27 checkResponseElement('div.sf_admin_filters input[name="filters[title]"][id="filters_title"]')-> 28 checkResponseElement('div.sf_admin_filters label[for=" body"]', 'Body:')->28 checkResponseElement('div.sf_admin_filters label[for="filters_body"]', 'Body:')-> 29 29 checkResponseElement('div.sf_admin_filters input[name="filters[body]"][id="filters_body"]')-> 30 checkResponseElement('div.sf_admin_filters label[for=" online"]', 'Online:')->30 checkResponseElement('div.sf_admin_filters label[for="filters_online"]', 'Online:')-> 31 31 checkResponseElement('div.sf_admin_filters select[name="filters[online]"][id="filters_online"] option', 3)-> 32 checkResponseElement('div.sf_admin_filters label[for=" category_id"]', 'Category:')->32 checkResponseElement('div.sf_admin_filters label[for="filters_category_id"]', 'Category:')-> 33 33 checkResponseElement('div.sf_admin_filters select[name="filters[category_id]"][id="filters_category_id"] option', 3)-> 34 checkResponseElement('div.sf_admin_filters label[for=" created_at"]', 'Created at:')->34 checkResponseElement('div.sf_admin_filters label[for="filters_created_at"]', 'Created at:')-> 35 35 checkResponseElement('div.sf_admin_filters input[name="filters[created_at][from]"][id="filters_created_at_from"]')-> 36 36 checkResponseElement('div.sf_admin_filters input[name="filters[created_at][to]"][id="filters_created_at_to"]') … … 39 39 $b-> 40 40 checkListCustomization('filters', array('filters' => array('title'), 'fields' => array('title' => array('filter_is_empty' => true))))-> 41 checkResponseElement('div.sf_admin_filters label[for="filters [title_is_empty]"]')41 checkResponseElement('div.sf_admin_filters label[for="filters_title_is_empty"]') 42 42 ; branches/dwhittle/lib/widget/sfWidgetFormSchema.class.php
r5943 r5999 32 32 $labels = array(), 33 33 $fields = array(), 34 $positions = array(); 34 $positions = array(), 35 $helps = array(); 35 36 36 37 /** … … 51 52 * @param array An array of options 52 53 * @param array An array of HTML labels 54 * @param array An array of help texts 53 55 * 54 56 * @see sfWidgetForm 55 57 */ 56 public function __construct($fields = null, $options = array(), $attributes = array(), $labels = array() )58 public function __construct($fields = null, $options = array(), $attributes = array(), $labels = array(), $helps = array()) 57 59 { 58 60 if (is_array($fields)) … … 186 188 * 187 189 * @param string The field name 188 * @param str ginThe label name190 * @param string The label name 189 191 */ 190 192 public function setLabel($name, $value) … … 203 205 { 204 206 return array_key_exists($name, $this->labels) ? $this->labels[$name] : ''; 207 } 208 209 /** 210 * Sets the help texts to render for each field. 211 * 212 * @param array An array of help texts 213 */ 214 public function setHelps($helps) 215 { 216 $this->helps = $helps; 217 } 218 219 /** 220 * Sets the help texts. 221 * 222 * @return array An array of help texts 223 */ 224 public function getHelps() 225 { 226 return $this->helps; 227 } 228 229 /** 230 * Sets a help text. 231 * 232 * @param string The field name 233 * @param string The help text 234 */ 235 public function setHelp($name, $help) 236 { 237 $this->helps[$name] = $help; 238 } 239 240 /** 241 * Gets a text help by field name. 242 * 243 * @param string The field name 244 * 245 * @return string The help text or an empty string if it is not defined 246 */ 247 public function getHelp($name) 248 { 249 return array_key_exists($name, $this->helps) ? $this->helps[$name] : ''; 205 250 } 206 251 … … 309 354 $error = $widget instanceof sfWidgetFormSchema ? array() : $error; 310 355 311 $rows[] = $formFormat->formatRow($label, $field, $error );356 $rows[] = $formFormat->formatRow($label, $field, $error, $this->getHelp($name)); 312 357 } 313 358 } branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatter.class.php
r5943 r5999 10 10 11 11 /** 12 * 12 * sfWidgetFormSchemaFormatter allows to format a form schema with HTML formats. 13 13 * 14 14 * @package symfony … … 21 21 protected 22 22 $rowFormat = '', 23 $helpFormat = '%help%', 23 24 $errorRowFormat = '', 24 25 $errorListFormatInARow = " <ul class=\"error_list\">\n%errors% </ul>\n", … … 33 34 '%field%' => $field, 34 35 '%error%' => $this->formatErrorsForRow($errors), 35 '%help%' => $ help,36 '%help%' => $this->formatHelp($help), 36 37 '%hidden_fields%' => is_null($hiddenFields) ? '%hidden_fields%' : $hiddenFields, 37 38 )); 39 } 40 41 public function formatHelp($help) 42 { 43 if (!$help) 44 { 45 return ''; 46 } 47 48 return strtr($this->getHelpFormat(), array('%help%' => $help)); 38 49 } 39 50 … … 150 161 return $this->decoratorFormat; 151 162 } 163 164 public function setHelpFormat($format) 165 { 166 $this->helpFormat = $format; 167 } 168 169 public function getHelpFormat() 170 { 171 return $this->helpFormat; 172 } 152 173 } branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatterList.class.php
r5943 r5999 22 22 $rowFormat = "<li>\n %error%%label%\n %field%%help%\n%hidden_fields%</li>\n", 23 23 $errorRowFormat = "<li>\n%errors%</li>\n", 24 $helpFormat = '<br />%help%', 24 25 $decoratorFormat = "<ul>\n %content%</ul>"; 25 26 } branches/dwhittle/lib/widget/sfWidgetFormSchemaFormatterTable.class.php
r5943 r5999 22 22 $rowFormat = "<tr>\n <th>%label%</th>\n <td>%error%%field%%help%%hidden_fields%</td>\n</tr>\n", 23 23 $errorRowFormat = "<tr><td colspan=\"2\">\n%errors%</td></tr>\n", 24 $helpFormat = '<br />%help%', 24 25 $decoratorFormat = "<table>\n %content%</table>"; 25 26 } branches/dwhittle/test/unit/widget/sfWidgetFormSchemaFormatterListTest.php
r5943 r5999 20 20 <li> 21 21 label 22 <input /> help22 <input /><br />help 23 23 </li> 24 24 branches/dwhittle/test/unit/widget/sfWidgetFormSchemaFormatterTableTest.php
r5943 r5999 20 20 <tr> 21 21 <th>label</th> 22 <td><input /> help</td>22 <td><input /><br />help</td> 23 23 </tr> 24 24 branches/dwhittle/test/unit/widget/sfWidgetFormSchemaTest.php
r5943 r5999 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 48, new lime_output_color());13 $t = new lime_test(50, new lime_output_color()); 14 14 15 15 $w1 = new sfWidgetFormInput(array(), array('class' => 'foo1')); … … 118 118 $t->is($w->generateLabelName('first_name'), 'A first name', '->setLabel() sets a label value'); 119 119 $t->is($w->getLabels(), array('first_name' => 'A first name'), '->getLabels() returns all current labels'); 120 121 // ->setHelps() ->getHelps() ->setHelp() ->getHelp() 122 $t->diag('->setHelps() ->getHelps() ->setHelp() ->getHelp()'); 123 $w = new sfWidgetFormSchema(); 124 $w->setHelps(array('first_name', 'Please, provide your first name')); 125 $t->is($w->getHelps(), array('first_name', 'Please, provide your first name'), '->setHelps() changes all help messages'); 126 $w->setHelp('last_name', 'Please, provide your last name'); 127 $t->is($w->getHelp('last_name'), 'Please, provide your last name', '->setHelp() changes one help message'); 120 128 121 129 // ->generateLabel()