2

I currently have a form that will let you create a family.

FamilyForm.php

$description = new Textarea(self::KEY_FAMILY_DESCRIPTION);
$description->setAttribute("id", self::KEY_FAMILY_DESCRIPTION);
$description->setLabel("Description");
$this->add($description);    

$status = new Hidden(self::KEY_FAMILY_STATUS);
$status->setAttribute("id", self::KEY_FAMILY_STATUS); 
$this->add($status); 

$save = new Button(self::KEY_SAVE_BTN);
$save->setAttributes(array("id", self::KEY_SAVE_BTN));
$save->setLabel("Save");
$save->setValue("Save");
$this->add($save);

Create.phtml

<?php echo ctrlGroup($this, ProjectFamilyForm::KEY_FAMILY_DESCRIPTION, !($this->admin)); ?>
<?php echo ctrlGroup($this, ProjectFamilyForm::KEY_FAMILY_STATUS, !($this->admin)); ?>
<div class="form-actions">
      <?php $save = $this->form->get(ProjectFamilyForm::KEY_SAVE_BTN); ?>
      <?php $save->setAttribute("class", "btn btn-primary"); ?>
      <?php echo $this->formSubmit($save); ?>

      <a class="btn" href="<?php echo $this->url('home'); ?>">Cancel</a>
</div>

This works and allows me to input the description and the status of the family upon creation. However, everytime a family is created the status should be "active". However, the setValue() method seems to not be working.

8
  • "but I get an error" - Being what exactly? Commented Feb 4, 2016 at 18:57
  • @A-2-A yeah, missed it on my copy and paste -_- Commented Feb 4, 2016 at 18:58
  • @Fred-ii- Call to a member function setAttribute() on a non-object Commented Feb 4, 2016 at 18:59
  • @A-2-A but is there any way I can do it from the form? Commented Feb 4, 2016 at 19:01
  • Hm.... not sure but you have setAttributes in plural from and setAttribute in singular form. Relevant?. Or, are they 2 seperate methods? Commented Feb 4, 2016 at 19:02

1 Answer 1

1

I am not expert of ZEND but to do this some ways are there:-

  1. most preferable way:- Make you db table field set type and set the default value to active.

  2. Create a hidden field with predefined active value.

Please check this link for help:- http://forums.zend.com/viewtopic.php?t=2079

Sign up to request clarification or add additional context in comments.

1 Comment

I ended up using the hidden field and got it working. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.