本文整理汇总了PHP中Zend\Form\Form::populate方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::populate方法的具体用法?PHP Form::populate怎么用?PHP Form::populate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Form
的用法示例。
在下文中一共展示了Form::populate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populate
/**
* Set up values from array
* @param array $values
* @return Zend_Form
*/
public function populate(array $values)
{
if (!empty($values['sysmap_id'])) {
$this->_appendParamsSubform($values['sysmap_id']);
} elseif (!empty($values['hash'])) {
$mapitem = $this->model->getParentByHash($values['hash']);
$this->_appendParamsSubform($mapitem->hash);
}
return parent::populate($values);
}
示例2: populate
public function populate(array $values)
{
if (!empty($values['id'])) {
$this->setLegend('Edit layout');
}
if (!empty($values['points'])) {
$points = $values['points'];
unset($values['points']);
foreach ($points as $point) {
$values['map_id'][] = $point->getMapId();
}
}
return parent::populate($values);
}
示例3: testCanPopulateCheckboxOptionsFromPostedData
/**
* @group ZF-2828
*/
public function testCanPopulateCheckboxOptionsFromPostedData()
{
$form = new Form(array('elements' => array('100_1' => array('MultiCheckbox', array('multiOptions' => array('100_1_1' => 'Agriculture', '100_1_2' => 'Automotive', '100_1_12' => 'Chemical', '100_1_13' => 'Communications'), 'required' => true)))));
$data = array('100_1' => array('100_1_1', '100_1_2', '100_1_12', '100_1_13'));
$form->populate($data);
$html = $form->render($this->getView());
foreach ($form->getElement('100_1')->getMultiOptions() as $key => $value) {
if (!preg_match('#(<input[^>]*' . $key . '[^>]*>)#', $html, $m)) {
$this->fail('Missing input for a given multi option: ' . $html);
}
$this->assertContains('checked="checked"', $m[1]);
}
}
示例4: testFormsShouldAllowResetting
/**
* @group ZF-3227
*/
public function testFormsShouldAllowResetting()
{
$form = new Form();
$foo = new \Zend\Form\SubForm(array('name' => 'foo', 'elements' => array('one' => 'text', 'two' => 'text')));
$form->addElement('text', 'bar')->addElement('text', 'baz')->addElement('text', 'bat')->addDisplayGroup(array('bar', 'bat'), 'barbat')->addSubForm($foo, 'foo');
$values = array('bar' => 'Bar Value', 'baz' => 'Baz Value', 'bat' => 'Bat Value', 'foo' => array('one' => 'One Value', 'two' => 'Two Value'));
$form->populate($values);
$test = $form->getValues();
$this->assertEquals($values, $test);
$form->reset();
$test = $form->getValues();
$this->assertNotEquals($values, $test);
$this->assertEquals(0, array_sum($test));
}