Hi,
I'm at my wits end on this one, so I'm hoping some of the great and
good here can help me out.
The client site is on cakePHP1.1 (and an upgrade is not on the cards
for quite sometime).
I have a very simple form which was always returning validation
message (from the setFlash - see code snippet below) but not any
validation errors (the validationErrors is returning Null when I
var_dump it) - so I removed the validation rules from the model and
still get the same behaviour.
I just don't understand what is going on here, so any help or pointers
gratefully received.
Thanks
PG
All relevant code posted below:
Model:
class SeoDefault extends AppModel {
var $name = 'SeoDefault';
/*var $validate = array(
'region_code' => VALID_NUMBER,
'section_id' => VALID_NUMBER,
'title' => VALID_NOT_EMPTY,
'blurb' => VALID_NOT_EMPTY
);*/
}
Controller:
class SeoDefaultsController extends AppController {
var $name = 'SeoDefaults';
var $helpers = array('Html', 'Form', 'Javascript','Pagination');
var $uses = array('SeoDefault','Section');
function admin_edit($id = null) {
$this->set('sections', $this->Section-
>generateList(null,null,null,'{n}.Section.id', '{n}.Section.name'));
if (empty($this->data)) {
if ($id) {
$this->data = $this->SeoDefault->read(null, $id);
}
} else {
$this->cleanUpFields();
if ($this->SeoDefault->save($this->data)) {
$this->Session->setFlash('The SEO Default has been saved');
$this->redirect('/admin/seo_defaults/index');
} else {
$this->Session->setFlash('Please correct errors below.');
}
}
}
}
Admin_Edit view:
<h1>SEO Default</h1>
<ul class="actions">
<li><?php echo $html->link('List SEO Defaults', '/admin/seo_defaults/
index'); ?></li>
<li><?php echo $html->link('New SEO Default', '/admin/seo_defaults/
edit'); ?></li>
</ul>
<form action="<?php echo $html->url('/admin/seo_defaults/edit/'.$html-
>tagValue('SeoDefault/id')); ?>" method="post">
<fieldset>
<legend>Edit SEO Default Details</legend>
<div class="spacer"></div>
<div class="required">
<?php echo $form->labelTag('SeoDefault/region_code', 'International
or UK');?>
<?php echo $html->selectTag('SeoDefault/
region_code',array("1"=>"UK","2"=>"International"),$html-
>tagValue('SeoDefault/region_code'), array(), array(), true, true);?
><div class="info">Which website does this apply to UK or
International</div>
<?php echo $html->tagErrorMsg('SeoDefault/region_code', 'Please
select the website that these defaults apply to.');?>
</div>
<div class="required">
<?php echo $form->labelTag('SeoDefault/section_id', 'Section');?>
<?php echo $html->selectTag('SeoDefault/section_id',$sections,$html-
>tagValue('SeoDefault/section_id'), array(), array(), true, true);?
><div class="info">The section of the website that these defaults
apply to. e.g. news</div>
<?php echo $html->tagErrorMsg('SeoDefault/section_id', 'Please select
the section that these defaults apply to.');?>
</div>
<div class="required">
<?php echo $form->labelTag('SeoDefault/title', 'Title');?>
<?php echo $html->input('SeoDefault/title');?><div class="info">The
Default Meta title. max. 65 chars.</div>
<?php echo $html->tagErrorMsg('SeoDefault/title', 'Please enter the
Meta Title');?>
</div>
<div class="required">
<?php echo $form->labelTag('SeoDefault/blurb', 'Desc.');?>
<?php echo $html->textarea('SeoDefault/blurb', array('cols' => '60',
'rows' => '12', 'class' => 'mceNoEditor'));?><div class="info">Please
provide the Meta description for this section. Max. 250 chars</div>
<?php echo $html->tagErrorMsg('SeoDefault/blurb', 'Please enter the
Meta Description.');?>
</div>
</fieldset>
<?php echo $html->hidden('SeoDefault/id')?>
<div class="submit">
<?php echo $html->submit('Save');?>
</div>
</form>
And in case it's useful the Model for the Section (again with
validation commented out):
class Section extends AppModel {
var $name = 'Section';
/*var $validate = array(
'name' => VALID_NOT_EMPTY,
);*/
}
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
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
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment