Welcome, Guest
Username: Password: Remember me

TOPIC: Firing a save event without seeing form

Firing a save event without seeing form 29 Sep 2015 11:41 #13525

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
Let me try and explain this..

I have a grid where users can browse deals.. if they find on they like one, they click 'Claim' and this brings up a model form for the 'ClaimedDeals' window, which has lots of prefilled HIDDEN fields by using filter_item in the URL (dealid for example) and auto propagates Created By, Creation Date. As soon as they click SAVE and CLOSE.. the new record is created without them actually needing to do anything

IN technical terms.. when user is on URL

index.php?option=com_mycomponent&view=deals

They click a button that opens in a modal

index.php?option=com_mycomponent&view=claimdeal&filter_dealid=3

The modal window has ALL fields hidden as they are prepopulated by the URL or autogenerated by the core system.. so all the user has to do is click SAVE&CLOSE (relabelled - I understand the ruies and want to claim this deal) and the new record is created in claimdeals with the logged in user as the created_by and owner of the record

Ideally, I would prefer to skip this modal window stage altogether as it is not needed

Can I fire a save event that will create a new record and replace this modal, with some information passed via a BUTTON or URL without having to open a MODAL window or FORM screen
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

Firing a save event without seeing form 29 Sep 2015 11:45 #13526

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Do it on the display function of your page. It will create a new record every time the page is called.

This is the code to use with an item model
$model->save(array(
  'id' => 0,
  'my field' => 'My value'
));

$item = $model->getItem()
Coding is now a piece of cake
Last Edit: 29 Sep 2015 11:45 by admin.
The administrator has disabled public write access.
The following user(s) said Thank You: MorganL

Firing a save event without seeing form 29 Sep 2015 12:35 #13529

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
Thats pretty powerful stuff, I will have to have a play as its a bit more powerful that I require, but still doable as I can just make a view that says

'Well done, you have claimed the deal' and fire the event. The user then closes the window as normal!
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

Firing a save event without seeing form 29 Sep 2015 12:38 #13530

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Cool !

The best, when you done that is to give this process work to the controller. Better coding.
The view, just call the controller task. Redirection will not occurs after process if you create a single function.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.070 seconds

Get Started