Re: Saving data to Has Many relationship table from single form in CakePHP 3
Thank you Jose. Now I am doing in that way. I will update you the result. Regards, Jipson On Tuesday, 5 August 2014 12:33:48 UTC+1, José Lorenzo wrote: > > Do as I told you in my previous message: input('related_propery.field') > > On Tuesday, August 5, 2014 11:19:29 AM UTC+2, Jipson Thomas wrote: >> >> Hi Jose, >> Sorry. What I said in my last thread that I re created my models ,views >> and controllers through bake (The code I pasted in an older thread was not >> from bake command.). The form created through bake doesn't include the user >> table inputs. I will paste the code of form generated through bake below. >> === >> >> >> Form->create($vendor); ?> >> >> >> > echo $this->Form->input('company_name'); >> echo $this->Form->input('logo_url'); >> echo $this->Form->input('email_domain'); >> echo $this->Form->input('phone'); >> echo $this->Form->input('fax'); >> echo $this->Form->input('website'); >> echo $this->Form->input('address'); >> echo $this->Form->input('country'); >> echo $this->Form->input('city'); >> echo $this->Form->input('state'); >> echo $this->Form->input('postalcode'); >> echo $this->Form->input('subscription_package'); >> echo $this->Form->input('status'); >> echo $this->Form->input('no_emails'); >> echo $this->Form->input('no_partners'); >> echo $this->Form->input('coupon_id'); >> echo $this->Form->input('language'); >> ?> >> >> Form->button(__('Submit')); ?> >> Form->end(); ?> >> >> >> >> >> Html->link(__('List Vendors'), ['action' => >> 'index']); ?> >> Html->link(__('List Coupons'), ['controller' => >> 'Coupons', 'action' => 'index']); ?> >> Html->link(__('New Coupon'), ['controller' => >> 'Coupons', 'action' => 'add']); ?> >> Html->link(__('List Partners'), ['controller' => >> 'Partners', 'action' => 'index']); ?> >> Html->link(__('New Partner'), ['controller' => >> 'Partners', 'action' => 'add']); ?> >> Html->link(__('List VendorManagers'), >> ['controller' => 'VendorManagers', 'action' => 'index']); ?> >> Html->link(__('New Vendor Manager'), ['controller' >> => 'VendorManagers', 'action' => 'add']); ?> >> >> >> >> == >> >> The above code is to create separate forms for each table. My requirement >> is to make a single signup form for all the 3 tables. >> >> Apologize to be a continuing burdan... >> >> Regards, >> Jipson >> >> >> On Tuesday, 5 August 2014 10:11:36 UTC+1, José Lorenzo wrote: >>> >>> I find hard to believe that the form you showed above was generated by >>> bake, but I can definitely look if there is any errors in the bake tool. >>> The reason I say that is that we are not using the 'UppercaseThing.field' >>> notation anymore, we use lowercase properties. >>> For example if Articles belongsTo Authors the form would look like: >>> >>> Form->input('title') ?> >>> Form->input('author.name') ?> >>> Form->input('author.email') ?> >>> >>> On Tuesday, August 5, 2014 10:48:56 AM UTC+2, Jipson Thomas wrote: Hi Jose, Yes , I did the controller, model and view creation through the bake console. But it is not helping me to save data from single form to multiple tables. In my case the vendor signup form is having the input fields to vendor table, vendor manager table and a user table. Would you please help me to find a solution on this? Regards, Jipson On Monday, 4 August 2014 18:26:48 UTC+1, José Lorenzo wrote: > > I would recommend that you use the bake console tool to create the > initial controller code and forms, that way I'm sure you will learn and > understand how forms should be structured. > > On Monday, August 4, 2014 5:46:29 PM UTC+2, Jipson Thomas wrote: >> >> Hi, >> When I change the controller code as follows, It saves in vendor >> table only and return a true value. >> >> $vendors = TableRegistry::get('Vendors'); >> >> if ($this->request->is('post')) { >> $vendor = new Vendor($this->request->data['Vendor']); >> $vendor->VendorManagers = [ >> new >> VendorManager($this->request->data['VendorManager']), >> ]; >> $vendor->Users = [ >> new User($this->request->data['User']), >> ]; >> //print_r($vendor); >> if ($vendors->save($vendor)) { >> $this->Flash->success(__('The vendor has been >> saved')); >> return $this->redirect(['action' => 'index']); >> } >> $this->Flash->error(__('Unable to add the vendor')); >> } >> $this->set('vendor', $vendor); >> $this->set('subscription_package', $id)
Re: Saving data to Has Many relationship table from single form in CakePHP 3
Do as I told you in my previous message: input('related_propery.field') On Tuesday, August 5, 2014 11:19:29 AM UTC+2, Jipson Thomas wrote: > > Hi Jose, > Sorry. What I said in my last thread that I re created my models ,views > and controllers through bake (The code I pasted in an older thread was not > from bake command.). The form created through bake doesn't include the user > table inputs. I will paste the code of form generated through bake below. > === > > > Form->create($vendor); ?> > > > echo $this->Form->input('company_name'); > echo $this->Form->input('logo_url'); > echo $this->Form->input('email_domain'); > echo $this->Form->input('phone'); > echo $this->Form->input('fax'); > echo $this->Form->input('website'); > echo $this->Form->input('address'); > echo $this->Form->input('country'); > echo $this->Form->input('city'); > echo $this->Form->input('state'); > echo $this->Form->input('postalcode'); > echo $this->Form->input('subscription_package'); > echo $this->Form->input('status'); > echo $this->Form->input('no_emails'); > echo $this->Form->input('no_partners'); > echo $this->Form->input('coupon_id'); > echo $this->Form->input('language'); > ?> > > Form->button(__('Submit')); ?> > Form->end(); ?> > > > > > Html->link(__('List Vendors'), ['action' => > 'index']); ?> > Html->link(__('List Coupons'), ['controller' => > 'Coupons', 'action' => 'index']); ?> > Html->link(__('New Coupon'), ['controller' => > 'Coupons', 'action' => 'add']); ?> > Html->link(__('List Partners'), ['controller' => > 'Partners', 'action' => 'index']); ?> > Html->link(__('New Partner'), ['controller' => > 'Partners', 'action' => 'add']); ?> > Html->link(__('List VendorManagers'), ['controller' > => 'VendorManagers', 'action' => 'index']); ?> > Html->link(__('New Vendor Manager'), ['controller' > => 'VendorManagers', 'action' => 'add']); ?> > > > > == > > The above code is to create separate forms for each table. My requirement > is to make a single signup form for all the 3 tables. > > Apologize to be a continuing burdan... > > Regards, > Jipson > > > On Tuesday, 5 August 2014 10:11:36 UTC+1, José Lorenzo wrote: >> >> I find hard to believe that the form you showed above was generated by >> bake, but I can definitely look if there is any errors in the bake tool. >> The reason I say that is that we are not using the 'UppercaseThing.field' >> notation anymore, we use lowercase properties. >> For example if Articles belongsTo Authors the form would look like: >> >> Form->input('title') ?> >> Form->input('author.name') ?> >> Form->input('author.email') ?> >> >> On Tuesday, August 5, 2014 10:48:56 AM UTC+2, Jipson Thomas wrote: >>> >>> Hi Jose, >>> Yes , I did the controller, model and view creation through the bake >>> console. But it is not helping me to save data from single form to multiple >>> tables. In my case the vendor signup form is having the input fields to >>> vendor table, vendor manager table and a user table. Would you please help >>> me to find a solution on this? >>> >>> Regards, >>> Jipson >>> >>> On Monday, 4 August 2014 18:26:48 UTC+1, José Lorenzo wrote: I would recommend that you use the bake console tool to create the initial controller code and forms, that way I'm sure you will learn and understand how forms should be structured. On Monday, August 4, 2014 5:46:29 PM UTC+2, Jipson Thomas wrote: > > Hi, > When I change the controller code as follows, It saves in vendor table > only and return a true value. > > $vendors = TableRegistry::get('Vendors'); > > if ($this->request->is('post')) { > $vendor = new Vendor($this->request->data['Vendor']); > $vendor->VendorManagers = [ > new > VendorManager($this->request->data['VendorManager']), > ]; > $vendor->Users = [ > new User($this->request->data['User']), > ]; > //print_r($vendor); > if ($vendors->save($vendor)) { > $this->Flash->success(__('The vendor has been saved')); > return $this->redirect(['action' => 'index']); > } > $this->Flash->error(__('Unable to add the vendor')); > } > $this->set('vendor', $vendor); > $this->set('subscription_package', $id); > $this->set('subscription_type', $payoption); > > On Monday, 4 August 2014 16:17:10 UTC+1, Jipson Thomas wrote: >> >> The save method is returning a false only not any error messages. >> >> On Monday, 4 August 2014 14:43:20 UTC+1, Jipson Thomas wrote: >
Re: Saving data to Has Many relationship table from single form in CakePHP 3
Hi Jose, Sorry. What I said in my last thread that I re created my models ,views and controllers through bake (The code I pasted in an older thread was not from bake command.). The form created through bake doesn't include the user table inputs. I will paste the code of form generated through bake below. === Form->create($vendor); ?> Form->input('company_name'); echo $this->Form->input('logo_url'); echo $this->Form->input('email_domain'); echo $this->Form->input('phone'); echo $this->Form->input('fax'); echo $this->Form->input('website'); echo $this->Form->input('address'); echo $this->Form->input('country'); echo $this->Form->input('city'); echo $this->Form->input('state'); echo $this->Form->input('postalcode'); echo $this->Form->input('subscription_package'); echo $this->Form->input('status'); echo $this->Form->input('no_emails'); echo $this->Form->input('no_partners'); echo $this->Form->input('coupon_id'); echo $this->Form->input('language'); ?> Form->button(__('Submit')); ?> Form->end(); ?> Html->link(__('List Vendors'), ['action' => 'index']); ?> Html->link(__('List Coupons'), ['controller' => 'Coupons', 'action' => 'index']); ?> Html->link(__('New Coupon'), ['controller' => 'Coupons', 'action' => 'add']); ?> Html->link(__('List Partners'), ['controller' => 'Partners', 'action' => 'index']); ?> Html->link(__('New Partner'), ['controller' => 'Partners', 'action' => 'add']); ?> Html->link(__('List VendorManagers'), ['controller' => 'VendorManagers', 'action' => 'index']); ?> Html->link(__('New Vendor Manager'), ['controller' => 'VendorManagers', 'action' => 'add']); ?> == The above code is to create separate forms for each table. My requirement is to make a single signup form for all the 3 tables. Apologize to be a continuing burdan... Regards, Jipson On Tuesday, 5 August 2014 10:11:36 UTC+1, José Lorenzo wrote: > > I find hard to believe that the form you showed above was generated by > bake, but I can definitely look if there is any errors in the bake tool. > The reason I say that is that we are not using the 'UppercaseThing.field' > notation anymore, we use lowercase properties. > For example if Articles belongsTo Authors the form would look like: > > Form->input('title') ?> > Form->input('author.name') ?> > Form->input('author.email') ?> > > On Tuesday, August 5, 2014 10:48:56 AM UTC+2, Jipson Thomas wrote: >> >> Hi Jose, >> Yes , I did the controller, model and view creation through the bake >> console. But it is not helping me to save data from single form to multiple >> tables. In my case the vendor signup form is having the input fields to >> vendor table, vendor manager table and a user table. Would you please help >> me to find a solution on this? >> >> Regards, >> Jipson >> >> On Monday, 4 August 2014 18:26:48 UTC+1, José Lorenzo wrote: >>> >>> I would recommend that you use the bake console tool to create the >>> initial controller code and forms, that way I'm sure you will learn and >>> understand how forms should be structured. >>> >>> On Monday, August 4, 2014 5:46:29 PM UTC+2, Jipson Thomas wrote: Hi, When I change the controller code as follows, It saves in vendor table only and return a true value. $vendors = TableRegistry::get('Vendors'); if ($this->request->is('post')) { $vendor = new Vendor($this->request->data['Vendor']); $vendor->VendorManagers = [ new VendorManager($this->request->data['VendorManager']), ]; $vendor->Users = [ new User($this->request->data['User']), ]; //print_r($vendor); if ($vendors->save($vendor)) { $this->Flash->success(__('The vendor has been saved')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('Unable to add the vendor')); } $this->set('vendor', $vendor); $this->set('subscription_package', $id); $this->set('subscription_type', $payoption); On Monday, 4 August 2014 16:17:10 UTC+1, Jipson Thomas wrote: > > The save method is returning a false only not any error messages. > > On Monday, 4 August 2014 14:43:20 UTC+1, Jipson Thomas wrote: >> >> Hi All, >> Would you please give me some details or samples of saving data from >> a single form to the tables main and has many relationships. I tries >> with >> the normal way by adding a modelname.fieldname on form and the sual >> newentity of main table but it through false on save(); Please help me >> to
Re: Saving data to Has Many relationship table from single form in CakePHP 3
I find hard to believe that the form you showed above was generated by bake, but I can definitely look if there is any errors in the bake tool. The reason I say that is that we are not using the 'UppercaseThing.field' notation anymore, we use lowercase properties. For example if Articles belongsTo Authors the form would look like: Form->input('title') ?> Form->input('author.name') ?> Form->input('author.email') ?> On Tuesday, August 5, 2014 10:48:56 AM UTC+2, Jipson Thomas wrote: > > Hi Jose, > Yes , I did the controller, model and view creation through the bake > console. But it is not helping me to save data from single form to multiple > tables. In my case the vendor signup form is having the input fields to > vendor table, vendor manager table and a user table. Would you please help > me to find a solution on this? > > Regards, > Jipson > > On Monday, 4 August 2014 18:26:48 UTC+1, José Lorenzo wrote: >> >> I would recommend that you use the bake console tool to create the >> initial controller code and forms, that way I'm sure you will learn and >> understand how forms should be structured. >> >> On Monday, August 4, 2014 5:46:29 PM UTC+2, Jipson Thomas wrote: >>> >>> Hi, >>> When I change the controller code as follows, It saves in vendor table >>> only and return a true value. >>> >>> $vendors = TableRegistry::get('Vendors'); >>> >>> if ($this->request->is('post')) { >>> $vendor = new Vendor($this->request->data['Vendor']); >>> $vendor->VendorManagers = [ >>> new VendorManager($this->request->data['VendorManager']), >>> ]; >>> $vendor->Users = [ >>> new User($this->request->data['User']), >>> ]; >>> //print_r($vendor); >>> if ($vendors->save($vendor)) { >>> $this->Flash->success(__('The vendor has been saved')); >>> return $this->redirect(['action' => 'index']); >>> } >>> $this->Flash->error(__('Unable to add the vendor')); >>> } >>> $this->set('vendor', $vendor); >>> $this->set('subscription_package', $id); >>> $this->set('subscription_type', $payoption); >>> >>> On Monday, 4 August 2014 16:17:10 UTC+1, Jipson Thomas wrote: The save method is returning a false only not any error messages. On Monday, 4 August 2014 14:43:20 UTC+1, Jipson Thomas wrote: > > Hi All, > Would you please give me some details or samples of saving data from a > single form to the tables main and has many relationships. I tries with > the > normal way by adding a modelname.fieldname on form and the sual newentity > of main table but it through false on save(); Please help me to fix this > > Regards, > Jipson > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Saving data to Has Many relationship table from single form in CakePHP 3
Hi Jose, Yes , I did the controller, model and view creation through the bake console. But it is not helping me to save data from single form to multiple tables. In my case the vendor signup form is having the input fields to vendor table, vendor manager table and a user table. Would you please help me to find a solution on this? Regards, Jipson On Monday, 4 August 2014 18:26:48 UTC+1, José Lorenzo wrote: > > I would recommend that you use the bake console tool to create the initial > controller code and forms, that way I'm sure you will learn and understand > how forms should be structured. > > On Monday, August 4, 2014 5:46:29 PM UTC+2, Jipson Thomas wrote: >> >> Hi, >> When I change the controller code as follows, It saves in vendor table >> only and return a true value. >> >> $vendors = TableRegistry::get('Vendors'); >> >> if ($this->request->is('post')) { >> $vendor = new Vendor($this->request->data['Vendor']); >> $vendor->VendorManagers = [ >> new VendorManager($this->request->data['VendorManager']), >> ]; >> $vendor->Users = [ >> new User($this->request->data['User']), >> ]; >> //print_r($vendor); >> if ($vendors->save($vendor)) { >> $this->Flash->success(__('The vendor has been saved')); >> return $this->redirect(['action' => 'index']); >> } >> $this->Flash->error(__('Unable to add the vendor')); >> } >> $this->set('vendor', $vendor); >> $this->set('subscription_package', $id); >> $this->set('subscription_type', $payoption); >> >> On Monday, 4 August 2014 16:17:10 UTC+1, Jipson Thomas wrote: >>> >>> The save method is returning a false only not any error messages. >>> >>> On Monday, 4 August 2014 14:43:20 UTC+1, Jipson Thomas wrote: Hi All, Would you please give me some details or samples of saving data from a single form to the tables main and has many relationships. I tries with the normal way by adding a modelname.fieldname on form and the sual newentity of main table but it through false on save(); Please help me to fix this Regards, Jipson >>> -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Saving data to Has Many relationship table from single form in CakePHP 3
I would recommend that you use the bake console tool to create the initial controller code and forms, that way I'm sure you will learn and understand how forms should be structured. On Monday, August 4, 2014 5:46:29 PM UTC+2, Jipson Thomas wrote: > > Hi, > When I change the controller code as follows, It saves in vendor table > only and return a true value. > > $vendors = TableRegistry::get('Vendors'); > > if ($this->request->is('post')) { > $vendor = new Vendor($this->request->data['Vendor']); > $vendor->VendorManagers = [ > new VendorManager($this->request->data['VendorManager']), > ]; > $vendor->Users = [ > new User($this->request->data['User']), > ]; > //print_r($vendor); > if ($vendors->save($vendor)) { > $this->Flash->success(__('The vendor has been saved')); > return $this->redirect(['action' => 'index']); > } > $this->Flash->error(__('Unable to add the vendor')); > } > $this->set('vendor', $vendor); > $this->set('subscription_package', $id); > $this->set('subscription_type', $payoption); > > On Monday, 4 August 2014 16:17:10 UTC+1, Jipson Thomas wrote: >> >> The save method is returning a false only not any error messages. >> >> On Monday, 4 August 2014 14:43:20 UTC+1, Jipson Thomas wrote: >>> >>> Hi All, >>> Would you please give me some details or samples of saving data from a >>> single form to the tables main and has many relationships. I tries with the >>> normal way by adding a modelname.fieldname on form and the sual newentity >>> of main table but it through false on save(); Please help me to fix this >>> >>> Regards, >>> Jipson >>> >> -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Saving data to Has Many relationship table from single form in CakePHP 3
Hi, When I change the controller code as follows, It saves in vendor table only and return a true value. $vendors = TableRegistry::get('Vendors'); if ($this->request->is('post')) { $vendor = new Vendor($this->request->data['Vendor']); $vendor->VendorManagers = [ new VendorManager($this->request->data['VendorManager']), ]; $vendor->Users = [ new User($this->request->data['User']), ]; //print_r($vendor); if ($vendors->save($vendor)) { $this->Flash->success(__('The vendor has been saved')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('Unable to add the vendor')); } $this->set('vendor', $vendor); $this->set('subscription_package', $id); $this->set('subscription_type', $payoption); On Monday, 4 August 2014 16:17:10 UTC+1, Jipson Thomas wrote: > > The save method is returning a false only not any error messages. > > On Monday, 4 August 2014 14:43:20 UTC+1, Jipson Thomas wrote: >> >> Hi All, >> Would you please give me some details or samples of saving data from a >> single form to the tables main and has many relationships. I tries with the >> normal way by adding a modelname.fieldname on form and the sual newentity >> of main table but it through false on save(); Please help me to fix this >> >> Regards, >> Jipson >> > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Saving data to Has Many relationship table from single form in CakePHP 3
The save method is returning a false only not any error messages. On Monday, 4 August 2014 14:43:20 UTC+1, Jipson Thomas wrote: > > Hi All, > Would you please give me some details or samples of saving data from a > single form to the tables main and has many relationships. I tries with the > normal way by adding a modelname.fieldname on form and the sual newentity > of main table but it through false on save(); Please help me to fix this > > Regards, > Jipson > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Saving data to Has Many relationship table from single form in CakePHP 3
Hi Jose Lorenzo, Thank you. I am following the book on following url to do this. http://book.cakephp.org/3.0/en/orm/table-objects.html Something is blocking to save data. My Table structure is as follows. === A Vendor Table A Vendor manager table with vendor_id and user_id fields A user table. *My Vendorstable.php file* = notEmpty('company_name','Company Name is required') ->notEmpty('postalcode','Zip /Postcode is required') ->notEmpty('subscription_package','Couldn\'t find a valid package') ->notEmpty('country','Country is required'); return $validator; } public function initialize(array $config) { $this->addBehavior('Timestamp', [ 'events' => [ 'Model.beforeSave' => [ 'created_on' => 'new', 'modified_on' => 'always', ] ] ]); $this->belongsTo('SubscriptionPackages', [ 'foreignKey' => 'subscription_package' ]); $this->hasMany('VendorManagers'); $this->hasMany('Users', [ 'through' => 'VendorManagers']); } } *VendorManagersTable.php* == addBehavior('Timestamp', [ 'events' => [ 'Model.beforeSave' => [ 'created_on' => 'new', 'modified_on' => 'always', ] ] ]); $this->belongsTo('Vendors'); $this->belongsTo('Users'); } } *UsersTable.php* === add('username', 'validFormat', [ 'rule' => 'email', 'message' => 'Username must be valid e-mail' ]) ->add('username', [ 'unique' => ['rule' => 'validateUnique', 'provider' => 'table'] ]) ->add('email', 'validFormat', [ 'rule' => 'email', 'message' => 'E-mail must be valid' ]) ->add('email', [ 'unique' => ['rule' => 'validateUnique', 'provider' => 'table'] ]) ->add('password', [ 'minLength' => [ 'rule' => ['minLength', 6], 'last' => true, 'message' => 'Password must have minimum %d characters.' ], 'maxLength' => [ 'rule' => ['maxLength', 15], 'message' => 'Password can have maximum %d characters' ] ]) ->notEmpty('role','A valid role is required'); return $validator; } public function initialize(array $config) { $this->addBehavior('Timestamp', [ 'events' => [ 'Model.beforeSave' => [ 'created_on' => 'new', 'modified_on' => 'always', ] ] ]); $this->hasMany('VendorManagers'); } } *Controller Function to save form* == public function buypackage($id,$payoption='monthly'){ $vendors = TableRegistry::get('Vendors'); $entity = $vendors->newEntity($this->request->data(), [ 'associated' => ['VendorManagers' => ['associated' => ['Users']] ] ]); if ($this->request->is('post')) { if ($this->Vendors->save($entity)) { $this->Flash->success(__('The vendor has been saved')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('Unable to add the vendor')); } $this->set('vendor', $vendors); $this->set('subscription_package', $id); $this->set('subscription_type', $payoption); } *Form - buypackage.ctp* === Flash->render('auth') ?> Form->create($vendor) ?> Form->input('Vendor.name',['label'=>'Vendor Name']) ?> Form->input('Vendor.logo', ['type' => 'file']);?> Form->input('Vendor.fax') ?> Form->input('Vendor.phone') ?> Form->input('Vendor.website') ?> Form->input('Vendor.address') ?> Form->input('Vendor.country') ?> Form->input('Vendor.city') ?> Form->input('Vendor.state') ?> Form->input('Vendor.postalcode',['label'=>'Zip / Post Code']) ?> Form->hidden('Vendor.subscription_package',['value' => $subscription_package]); ?> Form->input('User.email') ?> Form->input('User.password') ?> Form->input('User.conf_password',['label'=>'Confirm Password', 'type' => 'password']) ?> Form->input('User.title') ?> Form->input('User.first_name',['label'=>'First Name(s)']) ?> Form->input('User.laste_name') ?> Form->input('User.job_title') ?> Form->input('User.phone') ?> Form->hidden('Use
Re: Saving data to Has Many relationship table from single form in CakePHP 3
Have you tried following the instructions in the book? What is failing? On Monday, August 4, 2014 3:43:20 PM UTC+2, Jipson Thomas wrote: > > Hi All, > Would you please give me some details or samples of saving data from a > single form to the tables main and has many relationships. I tries with the > normal way by adding a modelname.fieldname on form and the sual newentity > of main table but it through false on save(); Please help me to fix this > > Regards, > Jipson > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.