1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: class Whups_Form_Admin_EditAttributeStepTwo extends Horde_Form
15: {
16: public function __construct(&$vars)
17: {
18: parent::__construct($vars, _("Edit Attribute"));
19:
20: $attribute = $vars->get('attribute');
21:
22: $info = $GLOBALS['whups_driver']->getAttributeDesc($attribute);
23:
24: $this->addHidden('', 'type', 'int', true, true);
25: $this->addHidden('', 'attribute', 'int', true, true);
26: $pname = &$this->addVariable(
27: _("Attribute Name"), 'attribute_name', 'text', true);
28: $pname->setDefault($info['name']);
29: $pdesc = &$this->addVariable(
30: _("Attribute Description"), 'attribute_description', 'text', true);
31: $pdesc->setDefault($info['description']);
32: $preq = &$this->addVariable(
33: _("Required Attribute?"), 'attribute_required', 'boolean', false);
34: $preq->setDefault($info['required']);
35:
36: $ptype = &$this->addVariable(
37: _("Attribute Type"), 'attribute_type', 'enum', true, false, null,
38: array(Whups::fieldTypeNames()));
39: $ptype->setAction(
40: Horde_Form_Action::factory(
41: array('whups', 'whups_reload'),
42: array('formname' => 'whups_form_admin_editattributesteptwo_reload')));
43: $ptype->setDefault($info['type']);
44:
45: $type = $vars->get('attribute_type');
46: if (empty($type)) {
47: $type = $info['type'];
48: }
49: foreach (Whups::fieldTypeParams($type) as $param => $param_info) {
50: $pparam = &$this->addVariable(
51: $param_info['label'],
52: 'attribute_params[' . $param . ']',
53: $param_info['type'],
54: false);
55: if (isset($info['params'][$param])) {
56: $pparam->setDefault($info['params'][$param]);
57: }
58: }
59: }
60:
61: }