Passing values from php template

  • demicanadian
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0

demicanadian created the topic: Passing values from php template

How can I pass values from joomla template to the form? I need a hidden field with an identifier, it can't be taken from the URL.
For example, if I load form using this code:
<?php
$modules = JModuleHelper::getModule('mod_breezingforms');
$modules->params = [
                    'ff_mod_name' => 'general_contact_form',
                    'ff_mod_page' => '1'
];
echo JModuleHelper::renderModule($modules);
?>

Is it possible to somehow pass values using params?
#232200
  • Posts: 2104
  • Karma: 65
  • Thank you received: 255

DarkoCujic replied the topic: Passing values from php template

Hey,

do you want to access your template parameters or those $modules->params from your code?

To access the template parameters, use this:
$this->execPieceByName('ff_InitLib');

$app = JFactory::getApplication('site');
$template = $app->getTemplate(true);
$param = $template->params->get('name-of-parameter', defaultValue);
// do a print_r($template->params) to see all available parameters if needed

ff_setValue('name-of-hidden-field', $param);

If you want to access your module params, I haven't tested with custom params like you're setting, but to get default module params, use this:
$this->execPieceByName('ff_InitLib');
jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_breezingforms', 'name-of-your-module');
$moduleParams = new JRegistry;
$moduleParams->loadString($module->params);
// as before, this also contains all the params, so to get a single, use the following
$param = $moduleParams->get('name-of-param', defaultValue);

ff_setValue('name-of-hidden-field', $param);

All the code is supposed to go to the Before Form piece in your form.

Alternatively, if this is a single occurence, you can store the value in your $_SESSION variable and access it easily from the form.

Regards,
Darko

Satisfied with our support? PayPal tips
===========
Need to renew Pro Support? Buy Here!
===========
Satisfied? Consider a membership!
===========
Like us on Facebook
===========
Support Crosstec and get ALL EXTENSIONS and professional support for just $5. Here!
#232246
  • demicanadian
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0

demicanadian replied the topic: Passing values from php template

Thanks for the answer, but it looks like I mixed up joomla and other framework names. What I meant is, I need to send data from the View that renders the form.

So ideally what I want to do is to send data using params from call to the module renderer. From what I understand, I can't just look into default values in mod_breezingforms from the form code as these are not values I pass from the view in my component that renders the form (I tried your code, with no dice).
#232250
  • Posts: 2104
  • Karma: 65
  • Thank you received: 255

DarkoCujic replied the topic: Passing values from php template

Hey,

unfortunately, without looking at the code and spending time trying to figure it out, there's not much I can do.

You're saying you have that code from your opening post and you want to access them from inside the form? You want to access 'ff_mod_name' or some other variable you added by yourself?
Are you sure it's being "attached" to the module at all?

Maybe this question is better suited for the Joomla forums since you can access basically anything you want to access from inside the form.

Regards,
Darko

Satisfied with our support? PayPal tips
===========
Need to renew Pro Support? Buy Here!
===========
Satisfied? Consider a membership!
===========
Like us on Facebook
===========
Support Crosstec and get ALL EXTENSIONS and professional support for just $5. Here!
#232273
Moderators: ForumSupporttomeperica
Time to create page: 0.069 seconds

New Support System

Dear Customers,

Users with active subscription have support priority which will be dona via ServiceDesk (My Account > Raise a ticket).
FREE Support topics will be answered when AND if there is time.

You can check support guidelines here : here

Regards,
Crosstec Team

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here