selected should be, well selected. but that is only working in the
edit view, and failing in the edit all view. in edit all it lists all
the options but fails to select those that are already chosen for the
record.
On May 3, 5:24 am, Andrei Mita <andrei.m...@gmail.com> wrote:
> Your problem is in the view?
>
>
>
> On Mon, May 3, 2010 at 3:15 PM, abocanegra <aaronbocane...@gmail.com> wrote:
> > I have created a multiple image upload that needs to have multiple
> > records edited to add in content such as title and tags. When I do a
> > regular edit it works fine, when I try to do the multiple edit the tag
> > select function fails to load the selected options as it does in a
> > regular edit. I have been struggling with this, any help would be
> > appreciated.
>
> > //////////////////////////////////////// Photo Controller
>
> > function edit($id = null) {
> > if (!$id && empty($this->data)) {
> > $this->Session->setFlash(sprintf(__('Invalid %s',
> > true), 'photo'));
> > $this->redirect(array('action' => 'index'));
> > }
> > if (!empty($this->data)) {
> > if ($this->Photo->save($this->data)) {
> > $this->Session->setFlash(sprintf(__('The %s
> > has been saved',
> > true), 'photo'));
> > $this->redirect(array('action' => 'index'));
> > } else {
> > $this->Session->setFlash(sprintf(__('The %s
> > could not be saved.
> > Please, try again.', true), 'photo'));
> > }
> > }
> > if (empty($this->data)) {
> > $this->data = $this->Photo->read(null, $id);
> > }
> > $tags = $this->Photo->Tag->find('list', array('fields' =>
> > array('Tag.tag')));
> > $this->set(compact('tags'));
> > }
>
> > function editall() {
> > if(!empty($this->data)) {
> > $this->Photo->saveAll($this->data['Photo']);
> > }
> > else {
> > $this->data['Photo'] = Set::combine($this->Photo->find('all'),
> > '{n}.Photo.id', '{n}.Photo');
> > }
> > $tags = $this->Photo->Tag->find('list', array('fields' =>
> > array('Tag.tag')));
> > $this->set(compact('tags'));
> > }
>
> > /////////////////////////////////////////////// Edit View
> > <div class="photos form">
> > <?php echo $this->Form->create('Photo');?>
> > <fieldset>
> > <legend><?php printf(__('Edit %s', true), __('Photo',
> > true)); ?></
> > legend>
> > <?php
> > echo $this->Form->input('id');
> > echo
> > $html->image('../../../uploads/images/photography/small/' .
> > $this->Form->value('Photo.image'));
> > echo $this->Form->input('title');
> > echo $this->Form->input('image');
> > echo $this->Form->input('client');
> > echo $this->Form->input('description');
> > echo $this->Form->input('Tag');
> > ?>
> > </fieldset>
> > <?php echo $this->Form->end(__('Submit', true));?>
> > </div>
>
> > ///////////////////////////////////////////// Edit View Output
> > <div class="input select">
> > <label for="TagTag">Tag</label>
> > <input type="hidden" name="data[Tag][Tag]" value="" id="TagTag_" />
> > <select name="data[Tag][Tag][]" multiple="multiple" id="TagTag">
> > <option value="1">Jewelery</option>
> > <option value="2" selected="selected">Headshot</option>
> > <option value="3" selected="selected">Product</option>
> > <option value="4" selected="selected">Location</option>
> > <option value="5" selected="selected">Travel</option>
> > <option value="6" selected="selected">Art</option>
> > <option value="7">HDR</option>
> > </select></div>
>
> > /////////////////////////////////////////////// Edit All View
> > <div class="photos form">
> > <?php echo $form->create('Photo', array('action'=>'editall'));?>
> > <fieldset>
> > <legend><?php printf(__('Edit All %s', true), __('Photos',
> > true)); ?
> > ></legend>
> > <?php
> > foreach($this->data['Photo'] as $key => $value) {
> > echo '<div class = "box">' . "\n";
>
> > echo $form->input('Photo.'.$key.'.id') . "\n";
> > echo $html->image('../../../uploads/images/photography/small/' .
> > $this->Form->value('Photo.'.$key.'.image')) . "\n";
> > echo $form->input('Photo.'.$key.'.title') . "\n";
> > echo $form->input('Photo.'.$key.'.client') . "\n";
> > echo $form->input('Photo.'.$key.'.description') . "\n";
> > echo $form->input('Tag.'.$key.'.tag') . "\n";
> > echo '</div>' . "\n";
> > }
> > ?>
> > </fieldset>
> > <?php echo $form->end('Save All Photos');?>
> > </div>
>
> > ///////////////////////////////////////////////////// Edit All Output
> > (for only on entry)
> > <div class="photos form">
> > <form id="PhotoEditallForm" method="post" action="/admin/photos/
> > editall" accept-charset="utf-8">
> > <div style="display:none;">
> > <input type="hidden" name="_method" value="POST" />
> > </div>
> > <fieldset>
>
> > <legend>Edit All Photos</legend>
> > <div class = "box">
> > <input type="hidden" name="data[Photo][7][id]" value="7"
> > id="Photo7Id" />
> > <img src="/admin/img/../../../uploads/images/photography/small/
> > 1272871729.jpg" alt="" />
> > <div class="input text">
> > <label for="Photo7Title">Title</label>
> > <input name="data[Photo][7][title]" type="text" maxlength="255"
> > value="testint" id="Photo7Title" />
> > </div>
> > <div class="input text">
> > <label for="Photo7Client">Client</label>
> > <input name="data[Photo][7][client]" type="text" maxlength="255"
> > value="test" id="Photo7Client" />
> > </div>
> > <div class="input textarea">
> > <label for="Photo7Description">Description</label>
> > <textarea name="data[Photo][7][description]" cols="30" rows="6"
> > id="Photo7Description" >test</textarea>
> > </div>
> > <div class="input select required">
> > <label for="Tag7Tag">Tag</label>
> > <select name="data[Tag][7][tag]" id="Tag7Tag">
> > <option value="1">Jewelery</option>
> > <option value="2">Headshot</option>
> > <option value="3">Product</option>
> > <option value="4">Location</option>
> > <option value="5">Travel</option>
> > <option value="6">Art</option>
> > <option value="7">HDR</option>
> > </select>
> > </div>
> > </div>
>
> > Thanks
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment