Passing parametre
Hi, This is really a PHP question, but it involves $form_state, so bear with me please. In my code at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no avail. Can you help me guys? Thanks in advance :)
night_pharmacy_table is a form submit callback. It already gets passed the $form parameter; you have got the function signature wrong. So you need to change function night_pharmacy_table($form_state) { to function night_pharmacy_table($form, &$form_state) { Documentation here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/... On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Hi,
This is really a PHP question, but it involves $form_state, so bear with me please.
In my code at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no avail. Can you help me guys?
Thanks in advance :)
Thanks Patrick, Unfortunately, night_pharmacy_table never gets called, and I have no clue why. Do you happen to have an idea? On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com> wrote:
night_pharmacy_table is a form submit callback. It already gets passed the $form parameter; you have got the function signature wrong.
So you need to change function night_pharmacy_table($form_state) { to function night_pharmacy_table($form, &$form_state) {
Documentation here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Hi,
This is really a PHP question, but it involves $form_state, so bear with me please.
In my code at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no avail. Can you help me guys?
Thanks in advance :)
implement your form submit element like; $form['actions']['submit'] = array( '#type' => 'button', '#value' => t('Submit'), '#submit' => array('night_pharmacy_table'), ); and make sure you clear the cache. On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Thanks Patrick,
Unfortunately, night_pharmacy_table never gets called, and I have no clue why. Do you happen to have an idea?
On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com> wrote:
night_pharmacy_table is a form submit callback. It already gets passed the $form parameter; you have got the function signature wrong.
So you need to change function night_pharmacy_table($form_state) { to function night_pharmacy_table($form, &$form_state) {
Documentation here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Hi,
This is really a PHP question, but it involves $form_state, so bear with me please.
In my code at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no avail. Can you help me guys?
Thanks in advance :)
-- Kind regards, Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
Look at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote:
implement your form submit element like; $form['actions']['submit'] = array( '#type' => 'button', '#value' => t('Submit'), '#submit' => array('night_pharmacy_table'), ); and make sure you clear the cache.
On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Thanks Patrick,
Unfortunately, night_pharmacy_table never gets called, and I have no clue why. Do you happen to have an idea?
On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com> wrote:
night_pharmacy_table is a form submit callback. It already gets passed the $form parameter; you have got the function signature wrong.
So you need to change function night_pharmacy_table($form_state) { to function night_pharmacy_table($form, &$form_state) {
Documentation here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Hi,
This is really a PHP question, but it involves $form_state, so bear with me please.
In my code at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no avail. Can you help me guys?
Thanks in advance :)
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
You shouldn't return anything in the callback function. you need to remove "return $source" line from there. Just for test purposes put this line in callback function and see if you can get any form error form_set_error('iller_select', 'Error.'); On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Look at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S
On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote:
implement your form submit element like; $form['actions']['submit'] = array( '#type' => 'button', '#value' => t('Submit'), '#submit' => array('night_pharmacy_table'), ); and make sure you clear the cache.
On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Thanks Patrick,
Unfortunately, night_pharmacy_table never gets called, and I have no clue why. Do you happen to have an idea?
On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com> wrote:
night_pharmacy_table is a form submit callback. It already gets passed the $form parameter; you have got the function signature wrong.
So you need to change function night_pharmacy_table($form_state) { to function night_pharmacy_table($form, &$form_state) {
Documentation here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Hi,
This is really a PHP question, but it involves $form_state, so bear with me please.
In my code at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no avail. Can you help me guys?
Thanks in advance :)
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards, Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
'#type' => 'button' won't execute a submit callback, try '#type' => 'submit' On 4 December 2013 13:16, Murat Günana <mgunana@gmail.com> wrote:
You shouldn't return anything in the callback function. you need to remove "return $source" line from there. Just for test purposes put this line in callback function and see if you can get any form error form_set_error('iller_select', 'Error.');
On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Look at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S
On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote:
implement your form submit element like; $form['actions']['submit'] = array( '#type' => 'button', '#value' => t('Submit'), '#submit' => array('night_pharmacy_table'), ); and make sure you clear the cache.
On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Thanks Patrick,
Unfortunately, night_pharmacy_table never gets called, and I have no clue why. Do you happen to have an idea?
On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com> wrote:
night_pharmacy_table is a form submit callback. It already gets passed the $form parameter; you have got the function signature wrong.
So you need to change function night_pharmacy_table($form_state) { to function night_pharmacy_table($form, &$form_state) {
Documentation here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
Hi,
This is really a PHP question, but it involves $form_state, so bear with me please.
In my code at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no avail. Can you help me guys?
Thanks in advance :)
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
According to the form api it should be able to do that. On 4 December 2013 13:17, John Morahan <john.morahan@gmail.com> wrote:
'#type' => 'button' won't execute a submit callback, try '#type' => 'submit'
On 4 December 2013 13:16, Murat Günana <mgunana@gmail.com> wrote:
You shouldn't return anything in the callback function. you need to remove "return $source" line from there. Just for test purposes put this line in callback function and see if you can get any form error form_set_error('iller_select', 'Error.');
On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Look at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S
On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote:
implement your form submit element like; $form['actions']['submit'] = array( '#type' => 'button', '#value' => t('Submit'), '#submit' => array('night_pharmacy_table'), ); and make sure you clear the cache.
On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Thanks Patrick,
Unfortunately, night_pharmacy_table never gets called, and I have no clue why. Do you happen to have an idea?
On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com>wrote:
night_pharmacy_table is a form submit callback. It already gets passed the $form parameter; you have got the function signature wrong.
So you need to change function night_pharmacy_table($form_state) { to function night_pharmacy_table($form, &$form_state) {
Documentation here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
> Hi, > > This is really a PHP question, but it involves $form_state, so bear > with me please. > > In my code at > http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no > avail. Can you help me guys? > > Thanks in advance :) >
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards, Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
So, what else can I check? On 4 December 2013 15:24, Murat Günana <mgunana@gmail.com> wrote:
According to the form api it should be able to do that.
On 4 December 2013 13:17, John Morahan <john.morahan@gmail.com> wrote:
'#type' => 'button' won't execute a submit callback, try '#type' => 'submit'
On 4 December 2013 13:16, Murat Günana <mgunana@gmail.com> wrote:
You shouldn't return anything in the callback function. you need to remove "return $source" line from there. Just for test purposes put this line in callback function and see if you can get any form error form_set_error('iller_select', 'Error.');
On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Look at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S
On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote:
implement your form submit element like; $form['actions']['submit'] = array( '#type' => 'button', '#value' => t('Submit'), '#submit' => array('night_pharmacy_table'), ); and make sure you clear the cache.
On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
Thanks Patrick,
Unfortunately, night_pharmacy_table never gets called, and I have no clue why. Do you happen to have an idea?
On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com>wrote:
> night_pharmacy_table is a form submit callback. It already gets > passed the $form parameter; you have got the function signature wrong. > > So you need to change > function night_pharmacy_table($form_state) { > to > function night_pharmacy_table($form, &$form_state) { > > > Documentation here: > https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/... > > > > > On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: > >> Hi, >> >> This is really a PHP question, but it involves $form_state, so bear >> with me please. >> >> In my code at >> http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no >> avail. Can you help me guys? >> >> Thanks in advance :) >> > >
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
Hi Muzaffer, You should consider to refactor using drupal coding standard, example from comment module: $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#access' => ($comment->cid && user_access('administer comments')) || variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || isset($form_state['comment_preview']), '#weight' => 19, ); $form['actions']['preview'] = array( '#type' => 'submit', '#value' => t('Preview'), '#access' => (variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED), '#weight' => 20, '#submit' => array('comment_form_build_preview'), ); https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/... Why you need to call a specific submit function, as you'll have for free "night_pharmacy_form_submit($form, &$form_state)" already executed by Drupal ? On Wed, Dec 4, 2013 at 3:46 PM, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
So, what else can I check?
On 4 December 2013 15:24, Murat Günana <mgunana@gmail.com> wrote:
According to the form api it should be able to do that.
On 4 December 2013 13:17, John Morahan <john.morahan@gmail.com> wrote:
'#type' => 'button' won't execute a submit callback, try '#type' => 'submit'
On 4 December 2013 13:16, Murat Günana <mgunana@gmail.com> wrote:
You shouldn't return anything in the callback function. you need to remove "return $source" line from there. Just for test purposes put this line in callback function and see if you can get any form error form_set_error('iller_select', 'Error.');
On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Look at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S
On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote:
implement your form submit element like; $form['actions']['submit'] = array( '#type' => 'button', '#value' => t('Submit'), '#submit' => array('night_pharmacy_table'), ); and make sure you clear the cache.
On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
> Thanks Patrick, > > Unfortunately, night_pharmacy_table never gets called, and I have no > clue why. Do you happen to have an idea? > > > On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com>wrote: > >> night_pharmacy_table is a form submit callback. It already gets >> passed the $form parameter; you have got the function signature wrong. >> >> So you need to change >> function night_pharmacy_table($form_state) { >> to >> function night_pharmacy_table($form, &$form_state) { >> >> >> Documentation here: >> https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/... >> >> >> >> >> On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: >> >>> Hi, >>> >>> This is really a PHP question, but it involves $form_state, so >>> bear with me please. >>> >>> In my code at >>> http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no >>> avail. Can you help me guys? >>> >>> Thanks in advance :) >>> >> >> >
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- [image: TWINBIT logo] <http://twinbit.it/> Paolo Mainardi *Twinbit Founder - CTO * *www*: twinbit.it *mobile*: (+39) 3401678089 *skype*: paolo_mainardi *linkedin*: paolomainardi <http://www.linkedin.com/in/paolomainardi> *twitter*: @paolomainardi <http://twitter.com/paolomainardi> *blog*: paolomainardi.com
Unbelievable, night_pharmacy_form_submit doesn't even get hit :S . See http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... On 4 December 2013 16:55, Paolo Mainardi <paolo@twinbit.it> wrote:
Hi Muzaffer,
You should consider to refactor using drupal coding standard, example from comment module:
$form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#access' => ($comment->cid && user_access('administer comments')) || variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || isset($form_state['comment_preview']), '#weight' => 19, ); $form['actions']['preview'] = array( '#type' => 'submit', '#value' => t('Preview'), '#access' => (variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED), '#weight' => 20, '#submit' => array('comment_form_build_preview'), );
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
Why you need to call a specific submit function, as you'll have for free "night_pharmacy_form_submit($form, &$form_state)" already executed by Drupal ?
On Wed, Dec 4, 2013 at 3:46 PM, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
So, what else can I check?
On 4 December 2013 15:24, Murat Günana <mgunana@gmail.com> wrote:
According to the form api it should be able to do that.
On 4 December 2013 13:17, John Morahan <john.morahan@gmail.com> wrote:
'#type' => 'button' won't execute a submit callback, try '#type' => 'submit'
On 4 December 2013 13:16, Murat Günana <mgunana@gmail.com> wrote:
You shouldn't return anything in the callback function. you need to remove "return $source" line from there. Just for test purposes put this line in callback function and see if you can get any form error form_set_error('iller_select', 'Error.');
On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
Look at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S
On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote:
> implement your form submit element like; > $form['actions']['submit'] = array( > '#type' => 'button', > '#value' => t('Submit'), > '#submit' => array('night_pharmacy_table'), > ); > and make sure you clear the cache. > > > On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: > >> Thanks Patrick, >> >> Unfortunately, night_pharmacy_table never gets called, and I have >> no clue why. Do you happen to have an idea? >> >> >> On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com>wrote: >> >>> night_pharmacy_table is a form submit callback. It already gets >>> passed the $form parameter; you have got the function signature wrong. >>> >>> So you need to change >>> function night_pharmacy_table($form_state) { >>> to >>> function night_pharmacy_table($form, &$form_state) { >>> >>> >>> Documentation here: >>> https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/... >>> >>> >>> >>> >>> On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: >>> >>>> Hi, >>>> >>>> This is really a PHP question, but it involves $form_state, so >>>> bear with me please. >>>> >>>> In my code at >>>> http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no >>>> avail. Can you help me guys? >>>> >>>> Thanks in advance :) >>>> >>> >>> >> > > > -- > Kind regards, > > Murat Gunana > Tel: 07927964976 > Email: mgunana@gmail.com >
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- [image: TWINBIT logo] <http://twinbit.it/>
Paolo Mainardi
*Twinbit Founder - CTO * *www*: twinbit.it *mobile*: (+39) 3401678089 *skype*: paolo_mainardi *linkedin*: paolomainardi <http://www.linkedin.com/in/paolomainardi> *twitter*: @paolomainardi <http://twitter.com/paolomainardi> *blog*: paolomainardi.com
You need to change submit type from "button" to "submit". For some reason it's not getting triggered. See discussion https://drupal.org/node/72855. The working one for you should be like $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), '#submit' => array('night_pharmacy_form_submit'), ); On 4 December 2013 22:48, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Unbelievable, night_pharmacy_form_submit doesn't even get hit :S . See http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy...
On 4 December 2013 16:55, Paolo Mainardi <paolo@twinbit.it> wrote:
Hi Muzaffer,
You should consider to refactor using drupal coding standard, example from comment module:
$form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#access' => ($comment->cid && user_access('administer comments')) || variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || isset($form_state['comment_preview']), '#weight' => 19, ); $form['actions']['preview'] = array( '#type' => 'submit', '#value' => t('Preview'), '#access' => (variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED), '#weight' => 20, '#submit' => array('comment_form_build_preview'), );
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
Why you need to call a specific submit function, as you'll have for free "night_pharmacy_form_submit($form, &$form_state)" already executed by Drupal ?
On Wed, Dec 4, 2013 at 3:46 PM, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
So, what else can I check?
On 4 December 2013 15:24, Murat Günana <mgunana@gmail.com> wrote:
According to the form api it should be able to do that.
On 4 December 2013 13:17, John Morahan <john.morahan@gmail.com> wrote:
'#type' => 'button' won't execute a submit callback, try '#type' => 'submit'
On 4 December 2013 13:16, Murat Günana <mgunana@gmail.com> wrote:
You shouldn't return anything in the callback function. you need to remove "return $source" line from there. Just for test purposes put this line in callback function and see if you can get any form error form_set_error('iller_select', 'Error.');
On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
> Look at > http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S > > > On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote: > >> implement your form submit element like; >> $form['actions']['submit'] = array( >> '#type' => 'button', >> '#value' => t('Submit'), >> '#submit' => array('night_pharmacy_table'), >> ); >> and make sure you clear the cache. >> >> >> On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: >> >>> Thanks Patrick, >>> >>> Unfortunately, night_pharmacy_table never gets called, and I have >>> no clue why. Do you happen to have an idea? >>> >>> >>> On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com>wrote: >>> >>>> night_pharmacy_table is a form submit callback. It already gets >>>> passed the $form parameter; you have got the function signature wrong. >>>> >>>> So you need to change >>>> function night_pharmacy_table($form_state) { >>>> to >>>> function night_pharmacy_table($form, &$form_state) { >>>> >>>> >>>> Documentation here: >>>> https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/... >>>> >>>> >>>> >>>> >>>> On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: >>>> >>>>> Hi, >>>>> >>>>> This is really a PHP question, but it involves $form_state, so >>>>> bear with me please. >>>>> >>>>> In my code at >>>>> http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no >>>>> avail. Can you help me guys? >>>>> >>>>> Thanks in advance :) >>>>> >>>> >>>> >>> >> >> >> -- >> Kind regards, >> >> Murat Gunana >> Tel: 07927964976 >> Email: mgunana@gmail.com >> > >
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- [image: TWINBIT logo] <http://twinbit.it/>
Paolo Mainardi
*Twinbit Founder - CTO * *www*: twinbit.it *mobile*: (+39) 3401678089 *skype*: paolo_mainardi *linkedin*: paolomainardi <http://www.linkedin.com/in/paolomainardi> *twitter*: @paolomainardi <http://twitter.com/paolomainardi> *blog*: paolomainardi.com
-- Kind regards, Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
You were right, I did. It's just that I have been told 'button' and 'submit' both could submit forms. On 5 December 2013 01:21, Murat Günana <mgunana@gmail.com> wrote:
You need to change submit type from "button" to "submit". For some reason it's not getting triggered.
See discussion https://drupal.org/node/72855.
The working one for you should be like
$form['actions']['submit'] = array( '#type' => 'submit',
'#value' => t('Submit'), '#submit' => array('night_pharmacy_form_submit'), );
On 4 December 2013 22:48, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Unbelievable, night_pharmacy_form_submit doesn't even get hit :S . See http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy...
On 4 December 2013 16:55, Paolo Mainardi <paolo@twinbit.it> wrote:
Hi Muzaffer,
You should consider to refactor using drupal coding standard, example from comment module:
$form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#access' => ($comment->cid && user_access('administer comments')) || variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || isset($form_state['comment_preview']), '#weight' => 19, ); $form['actions']['preview'] = array( '#type' => 'submit', '#value' => t('Preview'), '#access' => (variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED), '#weight' => 20, '#submit' => array('comment_form_build_preview'), );
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
Why you need to call a specific submit function, as you'll have for free "night_pharmacy_form_submit($form, &$form_state)" already executed by Drupal ?
On Wed, Dec 4, 2013 at 3:46 PM, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
So, what else can I check?
On 4 December 2013 15:24, Murat Günana <mgunana@gmail.com> wrote:
According to the form api it should be able to do that.
On 4 December 2013 13:17, John Morahan <john.morahan@gmail.com> wrote:
'#type' => 'button' won't execute a submit callback, try '#type' => 'submit'
On 4 December 2013 13:16, Murat Günana <mgunana@gmail.com> wrote:
> You shouldn't return anything in the callback function. you need to > remove "return $source" line from there. > Just for test purposes put this line in callback function and see if > you can get any form error form_set_error('iller_select', 'Error.'); > > > On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: > >> Look at >> http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S >> >> >> On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote: >> >>> implement your form submit element like; >>> $form['actions']['submit'] = array( >>> '#type' => 'button', >>> '#value' => t('Submit'), >>> '#submit' => array('night_pharmacy_table'), >>> ); >>> and make sure you clear the cache. >>> >>> >>> On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: >>> >>>> Thanks Patrick, >>>> >>>> Unfortunately, night_pharmacy_table never gets called, and I have >>>> no clue why. Do you happen to have an idea? >>>> >>>> >>>> On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com>wrote: >>>> >>>>> night_pharmacy_table is a form submit callback. It already gets >>>>> passed the $form parameter; you have got the function signature wrong. >>>>> >>>>> So you need to change >>>>> function night_pharmacy_table($form_state) { >>>>> to >>>>> function night_pharmacy_table($form, &$form_state) { >>>>> >>>>> >>>>> Documentation here: >>>>> https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/... >>>>> >>>>> >>>>> >>>>> >>>>> On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> This is really a PHP question, but it involves $form_state, so >>>>>> bear with me please. >>>>>> >>>>>> In my code at >>>>>> http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no >>>>>> avail. Can you help me guys? >>>>>> >>>>>> Thanks in advance :) >>>>>> >>>>> >>>>> >>>> >>> >>> >>> -- >>> Kind regards, >>> >>> Murat Gunana >>> Tel: 07927964976 >>> Email: mgunana@gmail.com >>> >> >> > > > -- > Kind regards, > > Murat Gunana > Tel: 07927964976 > Email: mgunana@gmail.com >
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- [image: TWINBIT logo] <http://twinbit.it/>
Paolo Mainardi
*Twinbit Founder - CTO * *www*: twinbit.it *mobile*: (+39) 3401678089 *skype*: paolo_mainardi *linkedin*: paolomainardi <http://www.linkedin.com/in/paolomainardi> *twitter*: @paolomainardi <http://twitter.com/paolomainardi> *blog*: paolomainardi.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
Oh, and thanks :) mto On 5 December 2013 08:56, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
You were right, I did. It's just that I have been told 'button' and 'submit' both could submit forms.
On 5 December 2013 01:21, Murat Günana <mgunana@gmail.com> wrote:
You need to change submit type from "button" to "submit". For some reason it's not getting triggered.
See discussion https://drupal.org/node/72855.
The working one for you should be like
$form['actions']['submit'] = array( '#type' => 'submit',
'#value' => t('Submit'), '#submit' => array('night_pharmacy_form_submit'), );
On 4 December 2013 22:48, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Unbelievable, night_pharmacy_form_submit doesn't even get hit :S . See http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy...
On 4 December 2013 16:55, Paolo Mainardi <paolo@twinbit.it> wrote:
Hi Muzaffer,
You should consider to refactor using drupal coding standard, example from comment module:
$form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#access' => ($comment->cid && user_access('administer comments')) || variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || isset($form_state['comment_preview']), '#weight' => 19, ); $form['actions']['preview'] = array( '#type' => 'submit', '#value' => t('Preview'), '#access' => (variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED), '#weight' => 20, '#submit' => array('comment_form_build_preview'), );
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/...
Why you need to call a specific submit function, as you'll have for free "night_pharmacy_form_submit($form, &$form_state)" already executed by Drupal ?
On Wed, Dec 4, 2013 at 3:46 PM, Muzaffer Tolga Ozses <tolga@ozses.net>wrote:
So, what else can I check?
On 4 December 2013 15:24, Murat Günana <mgunana@gmail.com> wrote:
According to the form api it should be able to do that.
On 4 December 2013 13:17, John Morahan <john.morahan@gmail.com>wrote:
> '#type' => 'button' won't execute a submit callback, try '#type' => > 'submit' > > > On 4 December 2013 13:16, Murat Günana <mgunana@gmail.com> wrote: > >> You shouldn't return anything in the callback function. you need to >> remove "return $source" line from there. >> Just for test purposes put this line in callback function and see >> if you can get any form error form_set_error('iller_select', >> 'Error.'); >> >> >> On 4 December 2013 12:59, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: >> >>> Look at >>> http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy.... I made the changes you suggested and no dice :S >>> >>> >>> On 4 December 2013 14:54, Murat Günana <mgunana@gmail.com> wrote: >>> >>>> implement your form submit element like; >>>> $form['actions']['submit'] = array( >>>> '#type' => 'button', >>>> '#value' => t('Submit'), >>>> '#submit' => array('night_pharmacy_table'), >>>> ); >>>> and make sure you clear the cache. >>>> >>>> >>>> On 4 December 2013 12:49, Muzaffer Tolga Ozses <tolga@ozses.net>wrote: >>>> >>>>> Thanks Patrick, >>>>> >>>>> Unfortunately, night_pharmacy_table never gets called, and I >>>>> have no clue why. Do you happen to have an idea? >>>>> >>>>> >>>>> On 4 December 2013 14:35, Patrick Dawkins <pjcdawkins@gmail.com>wrote: >>>>> >>>>>> night_pharmacy_table is a form submit callback. It already gets >>>>>> passed the $form parameter; you have got the function signature wrong. >>>>>> >>>>>> So you need to change >>>>>> function night_pharmacy_table($form_state) { >>>>>> to >>>>>> function night_pharmacy_table($form, &$form_state) { >>>>>> >>>>>> >>>>>> Documentation here: >>>>>> https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/... >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net >>>>>> > wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> This is really a PHP question, but it involves $form_state, so >>>>>>> bear with me please. >>>>>>> >>>>>>> In my code at >>>>>>> http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no >>>>>>> avail. Can you help me guys? >>>>>>> >>>>>>> Thanks in advance :) >>>>>>> >>>>>> >>>>>> >>>>> >>>> >>>> >>>> -- >>>> Kind regards, >>>> >>>> Murat Gunana >>>> Tel: 07927964976 >>>> Email: mgunana@gmail.com >>>> >>> >>> >> >> >> -- >> Kind regards, >> >> Murat Gunana >> Tel: 07927964976 >> Email: mgunana@gmail.com >> > >
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
-- [image: TWINBIT logo] <http://twinbit.it/>
Paolo Mainardi
*Twinbit Founder - CTO * *www*: twinbit.it *mobile*: (+39) 3401678089 *skype*: paolo_mainardi *linkedin*: paolomainardi <http://www.linkedin.com/in/paolomainardi> *twitter*: @paolomainardi <http://twitter.com/paolomainardi> *blog*: paolomainardi.com
-- Kind regards,
Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
Hi Muzaffer, Form submit callback function takes two parameters. You can implement your callback function like; function night_pharmacy_table($form, &$form_state) { // debug and implement form and form_state elements in here with your custom code. } On 4 December 2013 12:14, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Hi,
This is really a PHP question, but it involves $form_state, so bear with me please.
In my code at http://git.webciniz.im/?p=project/night_pharmacy.git;a=blob;f=night_pharmacy... want to be able to pass $form parameters to night_pharmacy_table, to no avail. Can you help me guys?
Thanks in advance :)
-- Kind regards, Murat Gunana Tel: 07927964976 Email: mgunana@gmail.com
participants (5)
-
John Morahan -
Murat Günana -
Muzaffer Tolga Ozses -
Paolo Mainardi -
Patrick Dawkins