Graham's way is way better. How did I not think of this! Thanks
Graham!
On Nov 20, 3:23 pm, Predominant <[EMAIL PROTECTED]> wrote:
> I do something similar, but I use element variables to indicate
> whether or not the ID field should be used:
>
> add.ctp / edit.ctp --- Just change the includeId to true / false as
> required, leaving it out defaults to false.
> <?php echo $this->element('users/form', array('includeId' => true)); ?
>
>
>
> views/elements/users/form.ctp
> <?php
> echo $form->create('User');
> if (isset($includeId) && $includeId) {
> echo $form->input('id');}
>
> echo $form->input('username');
> echo $form->input('password');
> echo $form->end('save');
> ?>
>
> Thus, your form inclusion code on the add / edit pages is minimalised.
> You can extend this to include other optional items.
>
> Cheers,
> Graham
>
> On Nov 21, 7:16 am, validkeys <[EMAIL PROTECTED]> wrote:
>
> > Another bit of advice that I could give you is this.
>
> > What I am guessing he is annoyed with is if he makes a change to the
> > form on the add view, he has to then laboriously navigate to the edit
> > view and make the same change. What I have been doing is this.
>
> > In the elements folder, I create a folder for each controller
> > (users).
>
> > Lets say my add form is:
>
> > <?php
> > echo $form->create('User');
> > echo $form->input('username');
> > echo $form->input('password');
> > echo $form->end('Submit')
> > ?>
>
> > and my edit form is:
>
> > <?php
> > echo $form->create('User');
> > echo $form->input('id')
> > echo $form->input('username');
> > echo $form->input('password');
> > echo $form->end('Submit')
> > ?>
>
> > To reduce coupling, I place the common elements in elements/users/
> > form.ctp and then just include it in the template like this:
>
> > <?php
> > echo $form->create('User');
> > echo $this->element('users/form');
> > echo $form->end('Submit');
> > ?>
>
> > <?php
> > echo $form->create('User');
> > echo $form->input('id');
> > echo $this->element('users/form');
> > echo $form->end('Submit');
> > ?>
>
> > This looks like more work when there are only 2 fields. But it's just
> > an example.
> > On Nov 20, 10:10 am, "[EMAIL PROTECTED]"
>
> > <[EMAIL PROTECTED]> wrote:
> > > I have an strange client that just can't get past the fact that view
> > > templates are, in his words "scattered across so many locations". Is
> > > there a way to set up a single folder and a name convention then tell
> > > the view where to find the files? For examples, all user templates
> > > would be something like user_add.ctp, user_edit.ctp, etc.
>
> > > Then he could edit as necessary.
>
> > > I try to convince him to keep his changes to the layout but he want to
> > > tweek every form, etc. He is odd.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---