本文整理匯總了PHP中sfWidgetFormSchema::moveField方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfWidgetFormSchema::moveField方法的具體用法?PHP sfWidgetFormSchema::moveField怎麽用?PHP sfWidgetFormSchema::moveField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfWidgetFormSchema
的用法示例。
在下文中一共展示了sfWidgetFormSchema::moveField方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: catch
$t->pass('->setPositions() throws an InvalidArgumentException if you give it a non existant field name');
}
try {
$w->setPositions(array('w1'));
$t->fail('->setPositions() throws an InvalidArgumentException if you miss a field name');
} catch (InvalidArgumentException $e) {
$t->pass('->setPositions() throws an InvalidArgumentException if you miss a field name');
}
// ->moveField()
$t->diag('->moveField()');
$w = new sfWidgetFormSchema();
$w['w1'] = $w1;
$w['w2'] = $w2;
$w['w3'] = $w1;
$w['w4'] = $w2;
$w->moveField('w1', sfWidgetFormSchema::BEFORE, 'w3');
$t->is($w->getPositions(), array('w2', 'w1', 'w3', 'w4'), '->moveField() can move a field before another one');
$w->moveField('w1', sfWidgetFormSchema::LAST);
$t->is($w->getPositions(), array('w2', 'w3', 'w4', 'w1'), '->moveField() can move a field to the end');
$w->moveField('w1', sfWidgetFormSchema::FIRST);
$t->is($w->getPositions(), array('w1', 'w2', 'w3', 'w4'), '->moveField() can move a field to the beginning');
$w->moveField('w1', sfWidgetFormSchema::AFTER, 'w3');
$t->is($w->getPositions(), array('w2', 'w3', 'w1', 'w4'), '->moveField() can move a field before another one');
try {
$w->moveField('w1', sfWidgetFormSchema::AFTER);
$t->fail('->moveField() throws an LogicException if you don\'t pass a relative field name with AFTER');
} catch (LogicException $e) {
$t->pass('->moveField() throws an LogicException if you don\'t pass a relative field name with AFTER');
}
try {
$w->moveField('w1', sfWidgetFormSchema::BEFORE);
示例2: sfWidgetFormSchema
$t->pass('->moveField() throws an LogicException if you don\'t pass a relative field name with BEFORE');
}
// this case is especially interesting because the numeric array keys are always
// converted to integers by array
// furthermore, (int)0 == (string)'w1' succeeds
$w = new sfWidgetFormSchema(array('w1' => $w1, '0' => $w2));
$w->moveField(0, sfWidgetFormSchema::FIRST);
$t->is($w->getPositions(), array('0', 'w1'), '->moveField() compares field names as strings');
$w = new sfWidgetFormSchema(array('w1' => $w1, '0' => $w2));
$w->moveField('0', sfWidgetFormSchema::FIRST);
$t->is($w->getPositions(), array('0', 'w1'), '->moveField() compares field names as strings');
$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2, '0' => $w1));
$w->moveField('w1', sfWidgetFormSchema::BEFORE, '0');
$t->is($w->getPositions(), array('w2', 'w1', '0'), '->moveField() compares field names as strings');
$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2, '0' => $w1));
$w->moveField('w1', sfWidgetFormSchema::BEFORE, 0);
$t->is($w->getPositions(), array('w2', 'w1', '0'), '->moveField() compares field names as strings');
// ->getGlobalErrors()
$t->diag('->getGlobalErrors()');
$w = new sfWidgetFormSchema();
$w['w1'] = $w1;
$w['w2'] = new sfWidgetFormInputHidden();
$w['w3'] = new sfWidgetFormSchema();
$w['w3']['w1'] = $w1;
$w['w3']['w2'] = new sfWidgetFormInputHidden();
$errors = array('global error', 'w1' => 'error for w1', 'w2' => 'error for w2', 'w4' => array('w1' => 'error for w4/w1', 'w2' => 'error for w4/w2', 'w3' => 'error for w4/w3'), 'w4' => 'error for w4');
$t->is($w->getGlobalErrors($errors), array('global error', 'error for w4', 'W2' => 'error for w2'), '->getGlobalErrors() returns an array of global errors, errors for hidden fields, and errors for non existent fields');
// ->render()
$t->diag('->render()');
$w = new sfWidgetFormSchema();
try {
示例3: catch
$t->pass('sfFormField implements the ArrayAccess interface but in read-only mode');
}
try {
$parent['title1'];
$t->fail('sfFormField implements the ArrayAccess interface but in read-only mode');
} catch (LogicException $e) {
$t->pass('sfFormField implements the ArrayAccess interface but in read-only mode');
}
// implements Countable
$t->diag('implements Countable');
$widgetSchema = new sfWidgetFormSchema(array('w1' => $w1 = new sfWidgetFormInputText(), 'w2' => $w2 = new sfWidgetFormInputText()));
$f = new sfFormFieldSchema($widgetSchema, null, 'article', array());
$t->is(count($f), 2, 'sfFormFieldSchema implements the Countable interface');
// implements Iterator
$t->diag('implements Iterator');
$f = new sfFormFieldSchema($widgetSchema, null, 'article', array());
$values = array();
foreach ($f as $name => $value) {
$values[$name] = $value;
}
$t->is(isset($values['w1']), true, 'sfFormFieldSchema implements the Iterator interface');
$t->is(isset($values['w2']), true, 'sfFormFieldSchema implements the Iterator interface');
$t->is(count($values), 2, 'sfFormFieldSchema implements the Iterator interface');
$t->diag('implements Iterator respecting the order of fields');
$widgetSchema->moveField('w2', 'first');
$f = new sfFormFieldSchema($widgetSchema, null, 'article', array());
$values = array();
foreach ($f as $name => $value) {
$values[$name] = $value;
}
$t->is(array_keys($values), array('w2', 'w1'), 'sfFormFieldSchema keeps the order');