Quantcast

beginner In CakePHP . HELP PLEASE

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

beginner In CakePHP . HELP PLEASE

Kalaiarasan Eswaramoorthy
HI to all,
I am a beginner in CakePHP.
I would like like to get help in my coding.
i am currently creating a directory using CakePHP.
the problem i am facing

1)when i click edit it is not redirecting to Edit,it just displaying
the Session message say "the post is saved"

2) when ever i click add after submit button is clicked it is not
adding anything in to Table.


please help me where do i want to start looking.


Thanks in Advance

Regards
Kalai

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: beginner In CakePHP . HELP PLEASE

Sam Sherlock

You need to show your code

Sounds like your missing parts of an if-statement in the edit action

- S

On 17 Feb 2012 17:59, "kalai" <[hidden email]> wrote:
HI to all,
I am a beginner in CakePHP.
I would like like to get help in my coding.
i am currently creating a directory using CakePHP.
the problem i am facing

1)when i click edit it is not redirecting to Edit,it just displaying
the Session message say "the post is saved"

2) when ever i click add after submit button is clicked it is not
adding anything in to Table.


please help me where do i want to start looking.


Thanks in Advance

Regards
Kalai

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: beginner In CakePHP . HELP PLEASE

Kalaiarasan Eswaramoorthy
Hi sam,
i have building , which has to be edit, delete, add.
here is the

Model of Building:
<?php
class Building extends AppModel {
        var $name = 'Building';
        //The Associations below have been created with all possible keys,
those that are not needed can be removed


        var $validate = array(
                'identifier' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),
                                'message' => 'Building alias can not be empty!',
                                //'allowEmpty' => false,
                                //'required' => false,
                                //'last' => false, // Stop validation after this rule
                                //'on' => 'create', // Limit validation to 'create' or 'update'
operations
                        ),
                        'alphanumeric' => array(
                                'rule' => array('alphanumeric'),
                                'message' => 'Special charcters not allowed!',
                                //'allowEmpty' => false,
                                //'required' => false,
                                //'last' => false, // Stop validation after this rule
                                //'on' => 'create', // Limit validation to 'create' or 'update'
operations
                        ),
                ),
                'name' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),
                                'message' => 'Building name can not be empty!',
                                //'allowEmpty' => false,
                                //'required' => false,
                                //'last' => false, // Stop validation after this rule
                                //'on' => 'create', // Limit validation to 'create' or 'update'
operations
                        ),
                        'lettersandspace' => array(
                                'rule' => '|^([A-Za-z ])*$|',
                                'message' => 'Special charcters not allowed!',
                                //'allowEmpty' => false,
                                //'required' => false,
                                //'last' => false, // Stop validation after this rule
                                //'on' => 'create', // Limit validation to 'create' or 'update'
operations
                        ),
                ),
                'zip' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),
                                'message' => 'Building zip can not be empty!',
                                //'allowEmpty' => false,
                                //'required' => false,
                                //'last' => false, // Stop validation after this rule
                                //'on' => 'create', // Limit validation to 'create' or 'update'
operations
                        ),
                        'zipformat' => array(
                                'rule' => '|^([7][3][0]\d{2})*$|',
                                'message' => 'Enter a correct zip code - 730XX!',
                                //'allowEmpty' => false,
                                //'required' => false,
                                //'last' => false, // Stop validation after this rule
                                //'on' => 'create', // Limit validation to 'create' or 'update'
operations
                        ),
                ),
                'address' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),
                                'message' => 'Building address can not be empty!',
                                //'allowEmpty' => false,
                                //'required' => false,
                                //'last' => false, // Stop validation after this rule
                                //'on' => 'create', // Limit validation to 'create' or 'update'
operations
                        ),
                        'addressformat' => array(
                                'rule' => '|^([0-9]{1,7} [a-zA-z\ \.]{2,35})*$|',
                                'message' => 'Invalid address format - use "1000 Main St."
format!',
                                //'allowEmpty' => false,
                                //'required' => false,
                                //'last' => false, // Stop validation after this rule
                                //'on' => 'create', // Limit validation to 'create' or 'update'
operations
                        ),
                ),
        );

}
?>

Controller of Building:
<?php
class BuildingsController extends AppController {

        var $name = 'Buildings';

        function index() {
                $this->Building->recursive = 0;
                $this->set('buildings', $this->paginate());
        }

        function view($id = null) {
                if (!$id) {
                        $this->Session->setFlash(__('Invalid building', true));
                        $this->redirect(array('action' => 'index'));
                }
                $this->set('building', $this->Building->read(null, $id));
        }

        function add() {
                if (empty($this->data)) {
                        $this->Building->create();
                        if ($this->Building->save($this->data)) {
                                $this->Session->setFlash(__('The building has been saved', true));
                                $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(__('The building could not be saved.
Please, try again.', true));
                        }
                }
        }

        function edit($id = null) {
                if (!$id && empty($this->data)) {
                        $this->Session->setFlash(__('Invalid building', true));
                        $this->redirect(array('action' => 'index'));
                }
                if (!empty($this->data)) {
                        if ($this->Building->save($this->data)) {
                                $this->Session->setFlash(__('The building has been saved', true));
                                $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(__('The building could not be saved.
Please, try again.', true));
                        }
                }
                if (empty($this->data)) {
                        $this->data = $this->Building->read(null, $id);
                }
        }

        function delete($id = null) {
                if (!$id) {
                        $this->Session->setFlash(__('Invalid id for building', true));
                        $this->redirect(array('action'=>'index'));
                }
                if ($this->Building->delete($id)) {
                        $this->Session->setFlash(__('Building deleted', true));
                        $this->redirect(array('action'=>'index'));
                }
                $this->Session->setFlash(__('Building was not deleted', true));
                $this->redirect(array('action' => 'index'));
        }
}
?>

view of building(edit).
<div class="buildings form">
<?php echo $this->Form->create('Building');?>
        <fieldset>
  <legend><?php __('Edit Building'); ?></legend>
        <?php
                echo $this->Form->input('id');
                echo $this->Form->input('identifier');
                echo $this->Form->input('name');
                echo $this->Form->input('address');
                echo $this->Form->input('city');
                echo $this->Form->input('state');
                echo $this->Form->input('zip');
        ?>
        </fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>

view Building(add)
<div class="buildings form">
<?php echo $this->Form->create('Building');?>
        <fieldset>
  <legend><?php __('Add Building'); ?></legend>
        <?php
                ?><label><?php __('Building Name Abbreviation/'); ?></label>
        <?php
        echo $this->Form->input('identifier');
                echo $this->Form->input('name');?>
        <label>Street Only</label>
    <?php
                echo $this->Form->input('address');
                echo $this->Form->hidden('city',array('value' => 'Norman'));
                echo $this->Form->hidden('state',array('value' => 'OK'));
                echo $this->Form->input('zip');
        ?>
        </fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>

please help me. i am struggling a lot

On Feb 17, 12:06 pm, Sam Sherlock <[hidden email]> wrote:

> You need to show your code
>
> Sounds like your missing parts of an if-statement in the edit action
>
> - S
> On 17 Feb 2012 17:59, "kalai" <[hidden email]> wrote:
>
>
>
>
>
>
>
> > HI to all,
> > I am a beginner in CakePHP.
> > I would like like to get help in my coding.
> > i am currently creating a directory using CakePHP.
> > the problem i am facing
>
> > 1)when i click edit it is not redirecting to Edit,it just displaying
> > the Session message say "the post is saved"
>
> > 2) when ever i click add after submit button is clicked it is not
> > adding anything in to Table.
>
> > please help me where do i want to start looking.
>
> > Thanks in Advance
>
> > Regards
> > Kalai
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > [hidden email] For more options, visit this group
> > athttp://groups.google.com/group/cake-php

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: beginner In CakePHP . HELP PLEASE

Sam Sherlock
@kalai
you need to check that $this->data is not empty when adding a building

been a while since I used 1.3 but I just baked a project after updating
my base of 1.3

I put you code in first without validation in the model (my view were
baked too)

I have not trouble editing buildings or adding new entries (after the
change on the if state of the add method - guess that was typo which is
why  baking is soo nice)

next I added the validation code.

I am not sure what your exact setup is for the buildings table or the
intended purpose of each field.
I see the identifier to my thinking this looks like your making an seo
friendly retrival field (if so look at the various slug behaviours out
there CakeDC Utils or Deuromark Tools plugins)

I see that in your views you are hard setting some stuff (certainly not
something I would do)

I am happy to give your actual sql setup a whirl if you like.

Also someone may well spot something I have missed

(I did not encounter that issue with the edit action)

On 17/02/2012 20:23, kalai wrote:

> function add() {
> if (!empty($this->data)) {
> $this->Building->create();
> if ($this->Building->save($this->data)) {
> $this->Session->setFlash(__('The building has been saved', true));
> $this->redirect(array('action' =>  'index'));
> } else {
> $this->Session->setFlash(__('The building could not be saved.
> Please, try again.', true));
> }
> }
> }

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: beginner In CakePHP . HELP PLEASE

Kalaiarasan Eswaramoorthy
Thank you Sam, for your kind reply building is one of the functionality, like Building there are Department,People,User,Group..etc..

I edited add function but still it has some other issues pooping up..
if you don't mind i would send my entire code and my table structure.?
can you help me please?

Thanks in Advance..
Regards
Kalai
On Fri, Feb 17, 2012 at 3:30 PM, Sam Sherlock <[hidden email]> wrote:
@kalai
you need to check that $this->data is not empty when adding a building

been a while since I used 1.3 but I just baked a project after updating my base of 1.3

I put you code in first without validation in the model (my view were baked too)

I have not trouble editing buildings or adding new entries (after the change on the if state of the add method - guess that was typo which is why  baking is soo nice)

next I added the validation code.

I am not sure what your exact setup is for the buildings table or the intended purpose of each field.
I see the identifier to my thinking this looks like your making an seo friendly retrival field (if so look at the various slug behaviours out there CakeDC Utils or Deuromark Tools plugins)

I see that in your views you are hard setting some stuff (certainly not something I would do)

I am happy to give your actual sql setup a whirl if you like.

Also someone may well spot something I have missed

(I did not encounter that issue with the edit action)

On 17/02/2012 20:23, kalai wrote:
function add() {
               if (!empty($this->data)) {

                       $this->Building->create();
                       if ($this->Building->save($this->data)) {
                               $this->Session->setFlash(__('The building has been saved', true));
                               $this->redirect(array('action' =>  'index'));
                       } else {
                               $this->Session->setFlash(__('The building could not be saved.
Please, try again.', true));
                       }
               }
       }

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: beginner In CakePHP . HELP PLEASE

Kalaiarasan Eswaramoorthy
In reply to this post by Sam Sherlock
Hi Sam Thanks for your kind Reply.
i changed the edit function still i have that issue..
i thought better understanding of my functionality will help you
better to help me..
If don't mind i would send my entire code and my table structure, so
that i can get exactly what i whant
can you help me in this, please?

Thanks in  advance

with Regards
kalai.


On Feb 17, 3:30 pm, Sam Sherlock <[hidden email]> wrote:

> @kalai
> you need to check that $this->data is not empty when adding a building
>
> been a while since I used 1.3 but I just baked a project after updating
> my base of 1.3
>
> I put you code in first without validation in the model (my view were
> baked too)
>
> I have not trouble editing buildings or adding new entries (after the
> change on the if state of the add method - guess that was typo which is
> why  baking is soo nice)
>
> next I added the validation code.
>
> I am not sure what your exact setup is for the buildings table or the
> intended purpose of each field.
> I see the identifier to my thinking this looks like your making an seo
> friendly retrival field (if so look at the various slug behaviours out
> there CakeDC Utils or Deuromark Tools plugins)
>
> I see that in your views you are hard setting some stuff (certainly not
> something I would do)
>
> I am happy to give your actual sql setup a whirl if you like.
>
> Also someone may well spot something I have missed
>
> (I did not encounter that issue with the edit action)
>
> On 17/02/2012 20:23, kalai wrote:
>
>
>
>
>
>
>
> > function add() {
> >            if (!empty($this->data)) {
> >                    $this->Building->create();
> >                    if ($this->Building->save($this->data)) {
> >                            $this->Session->setFlash(__('The building has been saved', true));
> >                            $this->redirect(array('action' =>  'index'));
> >                    } else {
> >                            $this->Session->setFlash(__('The building could not be saved.
> > Please, try again.', true));
> >                    }
> >            }
> >    }

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: beginner In CakePHP . HELP PLEASE

Sam Sherlock
 > Building there are Department,People,User,Group..etc..

I was hoping to see the sql and the problem model & controller
with the code being in bin.cakephp.org or github gist

have you got debug on in your app?
have you got debug_kit? its a must really

when you get an isssue with some controller action you can use
$this->log($aVartoDebug, 'file-to-save-it-in');
this will make a log file in tmp/logs and put the value of the first arg

also is you have a controller working comparing it with the one that
does not is very helpful.

Overall though taking some time to complete the blog tutorial and redo
it adding more
will teach  you much.

setting up bake will save you from many annoying human error typos and
save lots of time.
Its or so very easy to setup

finally if you are starting out why start with 1.3 when you could just
start with 2.0?


On 17/02/2012 21:57, kalai wrote:

> Hi Sam Thanks for your kind Reply.
> i changed the edit function still i have that issue..
> i thought better understanding of my functionality will help you
> better to help me..
> If don't mind i would send my entire code and my table structure, so
> that i can get exactly what i whant
> can you help me in this, please?
>
> Thanks in  advance
>
> with Regards
> kalai.
>
>
> On Feb 17, 3:30 pm, Sam Sherlock<[hidden email]>  wrote:
>> @kalai
>> you need to check that $this->data is not empty when adding a building
>>
>> been a while since I used 1.3 but I just baked a project after updating
>> my base of 1.3
>>
>> I put you code in first without validation in the model (my view were
>> baked too)
>>
>> I have not trouble editing buildings or adding new entries (after the
>> change on the if state of the add method - guess that was typo which is
>> why  baking is soo nice)
>>
>> next I added the validation code.
>>
>> I am not sure what your exact setup is for the buildings table or the
>> intended purpose of each field.
>> I see the identifier to my thinking this looks like your making an seo
>> friendly retrival field (if so look at the various slug behaviours out
>> there CakeDC Utils or Deuromark Tools plugins)
>>
>> I see that in your views you are hard setting some stuff (certainly not
>> something I would do)
>>
>> I am happy to give your actual sql setup a whirl if you like.
>>
>> Also someone may well spot something I have missed
>>
>> (I did not encounter that issue with the edit action)
>>
>> On 17/02/2012 20:23, kalai wrote:
>>
>>
>>
>>
>>
>>
>>
>>> function add() {
>>>             if (!empty($this->data)) {
>>>                     $this->Building->create();
>>>                     if ($this->Building->save($this->data)) {
>>>                             $this->Session->setFlash(__('The building has been saved', true));
>>>                             $this->redirect(array('action' =>    'index'));
>>>                     } else {
>>>                             $this->Session->setFlash(__('The building could not be saved.
>>> Please, try again.', true));
>>>                     }
>>>             }
>>>     }

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: beginner In CakePHP . HELP PLEASE

Kalaiarasan Eswaramoorthy
Hi Thanks, first of all i am starting to edit already existing code developed in 1.3 version..
i added some actions in it , as i am new to cakePHP i just followed the tutorial...
in this i am attaching the entire code.
so please help to figure it out...

please find the attachment

regards
Kalai

On Fri, Feb 17, 2012 at 5:48 PM, Sam Sherlock <[hidden email]> wrote:
> Building there are Department,People,User,Group..etc..

I was hoping to see the sql and the problem model & controller
with the code being in bin.cakephp.org or github gist

have you got debug on in your app?
have you got debug_kit? its a must really

when you get an isssue with some controller action you can use
$this->log($aVartoDebug, 'file-to-save-it-in');
this will make a log file in tmp/logs and put the value of the first arg

also is you have a controller working comparing it with the one that does not is very helpful.

Overall though taking some time to complete the blog tutorial and redo it adding more
will teach  you much.

setting up bake will save you from many annoying human error typos and save lots of time.
Its or so very easy to setup

finally if you are starting out why start with 1.3 when you could just start with 2.0?



On 17/02/2012 21:57, kalai wrote:
Hi Sam Thanks for your kind Reply.
i changed the edit function still i have that issue..
i thought better understanding of my functionality will help you
better to help me..
If don't mind i would send my entire code and my table structure, so
that i can get exactly what i whant
can you help me in this, please?

Thanks in  advance

with Regards
kalai.


On Feb 17, 3:30 pm, Sam Sherlock<[hidden email]>  wrote:
@kalai
you need to check that $this->data is not empty when adding a building

been a while since I used 1.3 but I just baked a project after updating
my base of 1.3

I put you code in first without validation in the model (my view were
baked too)

I have not trouble editing buildings or adding new entries (after the
change on the if state of the add method - guess that was typo which is
why  baking is soo nice)

next I added the validation code.

I am not sure what your exact setup is for the buildings table or the
intended purpose of each field.
I see the identifier to my thinking this looks like your making an seo
friendly retrival field (if so look at the various slug behaviours out
there CakeDC Utils or Deuromark Tools plugins)

I see that in your views you are hard setting some stuff (certainly not
something I would do)

I am happy to give your actual sql setup a whirl if you like.

Also someone may well spot something I have missed

(I did not encounter that issue with the edit action)

On 17/02/2012 20:23, kalai wrote:







function add() {
           if (!empty($this->data)) {
                   $this->Building->create();
                   if ($this->Building->save($this->data)) {
                           $this->Session->setFlash(__('The building has been saved', true));
                           $this->redirect(array('action' =>    'index'));
                   } else {
                           $this->Session->setFlash(__('The building could not be saved.
Please, try again.', true));
                   }
           }
   }

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: beginner In CakePHP . HELP PLEASE

phpMagpie
If you are new to CakePHP then you need to read through the book a couple of times before jumping into a project.  Bake some seperate projects and look at the code produced, if you're having problems with basic CRUD functions then they are all done for you when you bake.

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Loading...