Using POST function in Smarty - php

Can someone explain to me the exact steps on how to use the post function in Smarty PHP? I have to be leaving something out somewhere, and I'm not sure what. I'm workingin CMSMadeSimple and I want to post a variable from one form to another, except the variable doesn't exist in the first form. What are the steps I need to take to do this?
Clarification: I am using a module in CMSMS called FormBuilder. This module is accessing info from Products, another module. Now, these fields are what I'm trying to access. For instance, I am trying to pass info from the first form to a field in the second form which should be selected, where the name is "cntnt01" and the value is "205".

To assign the variable where it will be available to the first form, you need to call $smarty->assign() in the PHP script that produces the first form:
// Assuming your Smarty object is $smarty
$smarty->assign('variablename', $variablename);

Related

Accessing x-modal data and storing in database

I am having some trouble accessing x-model data in my laravel app and storing it into my database. Wondering if anyone can help.
So the issue seems to be coming from the fact that I have the category select as a separate blade that I call multiple times.
So ultimately, this code is called three times on my main page. I can then choose three separate categories - but when I try to call those selections and store them in database I run into an error.
Wondering if anyone has any ideas how to access the three separate categories being selected and add them to database. Some links or documentation to check out would be mighty helpful!
Using alpinejs, php, and laravel.
EDIT
In this particular case I am passing the information into the blade through the controller.
EDIT 2:this shows $selection_id
x-model takes the name of a variable inside x-data, not the value.
$selection_id here is a value.
You should do something like:
x-data="{ selection_id: {{$selection_id}} }"
on the component element
then inside x-model:
x-model="selection_id"
Note: Your code is missing, please add the part with the `x-data showing.

Drupal 7 - How to edit a value stored in variable table

I have inherited a multi-site in Drupal 7. There is a page where the client needs to edit the title element but this page is not a content type, a block or a taxonomy item!? I have queried the db and found only one instance of the value which needs to be changed. It is stored in the Variable table. If I change the value here the value changes as expected on the site. Can anyone shed any light on where the administration page is likely to be for this value based on the location of the value? I guess this could be defined anywhere really but was hoping someone may have come across this before.
You can change any variable value by using variable_set.
// Example
variable_set('variable_name', 'value to save');
Another way is to use devel module. After enabling the module; Go to ?q=devel/variable, find the variable you need to change from the table and click on Edit next to it.
The values of variables in Drupal can be set in a couple of ways:
From code - Using variable_set() function.
Look in the code if anywhere this function is called to set the value of the variable. If this is the case, you can implement your own module with some configuration form to override the value of the variable.
From a form defined using the Form API - Using system_settings_form() function.
I'll suggest you to look for the name of the variable who's value is used to set the page title, and then search in the code if there is a form element by that name, which is returned using system_settings_form. Then find out where this form is rendered - might be at some menu. After which you can change the value of this variable from the form itself.

Multi-select does not retain value after post in codeigniter

I have a form in my application with a multi select. I'm using CI's form helper to build my forms, so the build of the element looks like this:
return form_multiselect('authors[response][]', $faculty->get_all_for_multiselect(),
$pre_selected, $additional_attributes);
This is all well and good if the items are in the database ($pre_selected gets existing responses). However, I'm also running the form through CI's form validation, and when that happens, if validation fails, then the multi select loses the values that had been selected.
I'm sure this is something simple that I'm just over looking, so hopefully someone can help me out here.
Adding more information
The field is marked as required so it is going through the validator (although it will always pass as I'm automatically selecting the current user).
(I'm assuming $pre_selected is an array of values?)
You can reset selected values after failed form submit using the $_POST array.
Since you're already using $pre_selected, you should be able to use the following:
return form_multiselect('authors[response][]', $faculty->get_all_for_multiselect(),
array_unique(array_merge($pre_selected, $_POST['response'])), $additional_attributes);

how to read a webform with php

I am trying to do something really basic but can not seem to find a tutorial for it.
I have created a simple web form using HTML what I need todo is create a php file that will read the web form, open a new browser window (or display in same page) the contents of the web form, do toy guys have any tutorials on this?
Many thanks
Chris
I'm sure many will post different links to tutorials that they like, but I thought I would just give you the basic. The key parts to the form are the method and action. The Method attribute tells ths browser how to submit the data, either through GET or POST. The action attribute tells the browser where to submit the form. (In your case it will be, somepage.php) If you ever need the form to submit back to itself, you can here use explicitly type the page name or you can use use PHP to dynamically insert the page name. Finally, make sure that all your form fields use the name attribute, as this is how php will access the elements.
On the php side of things, your form variables will be stored in either $_GET or $_POST depending on how on method you used to submit your form. For example, assume you have a input element of type text with the name 'FirstName'. Within php you can access this by doing
<?php
var firstName = $_GET['FirstName'];
?>
This should be enough to get you started. Be sure to check out the php docs and the other tutorials listed on this page for a more details.
Please look at this tutorial: http://www.learnphp-tutorial.com/HtmlForms.cfm
And you can find many more tutorials if you search it on Google.
This should help : http://www.php-mysql-tutorial.com/wikis/php-tutorial/php-forms.aspx

Custom drupal form with predetermined values

I need to customise my forms in drupal so that each field has a value placed in it using a php script.
I have a php script which takes a url and gets a page title and meta description. It's easy enough to pass these values into a form by placing the required php in the input value. I can do this on a static 'test' form.
However, I'm not sure how to do this with a node form as I don't directly have access to the input value.
Any ideas or solutions would be greatly appreciated.
Use hook_form_alter() in order to alter some existing form entity. A basic knowledge about Form API and module development is sufficient.
I'd suggest using JavaScript to accomplish this since it's very good at manipulating form values (in Drupal too). If you can get the variables in JavaScript then it would be as simple as setting the input id value on page load.

Categories