- Posts: 39
- Thank you received: 0
Insert datas to db via the backend (form.php)
13 years 5 months ago #96829
by Storm15
Insert datas to db via the backend (form.php) was created by Storm15
Hello Everybody,
I wanted to add some extra options in the backend when creating/editing a product (availability for 3 kinds of conditions (new, used etc).
I added 3 checkboxes in the form.php file (administrator/com_hikashop/views/product/...) and now wanted to insert a boolean to the database if the checkbox was selected (=1) or not (=0).
I already created 3 columns in jos_hikashop_product, but I need the file or the function which inserts/updates the data to the database after clicking on "Save" in the backend.
It would be great if someone could help me with that one,
greetings,
David
I wanted to add some extra options in the backend when creating/editing a product (availability for 3 kinds of conditions (new, used etc).
I added 3 checkboxes in the form.php file (administrator/com_hikashop/views/product/...) and now wanted to insert a boolean to the database if the checkbox was selected (=1) or not (=0).
I already created 3 columns in jos_hikashop_product, but I need the file or the function which inserts/updates the data to the database after clicking on "Save" in the backend.
It would be great if someone could help me with that one,
greetings,
David
Please Log in or Create an account to join the conversation.
13 years 5 months ago #96855
by nicolas
Replied by nicolas on topic Insert datas to db via the backend (form.php)
Hi,
You should just set an input name like that: data[product][column_name]
where column name is the name of the column in the product table in the database and then the system will handle the field automatically without you doing anything.
Otherwise, you're lookinf for the function saveForm of the file administrator/components/com_hikashop/classes/product.php
You should just set an input name like that: data[product][column_name]
where column name is the name of the column in the product table in the database and then the system will handle the field automatically without you doing anything.
Otherwise, you're lookinf for the function saveForm of the file administrator/components/com_hikashop/classes/product.php
Please Log in or Create an account to join the conversation.
13 years 5 months ago #96985
by Storm15
Replied by Storm15 on topic Insert datas to db via the backend (form.php)
Okay I will try it with the data[product]...
But what does it exactly do? In form.php there are a few lines e.g
It would be great if someone could explain how it works and what happens to the $this->product.. Variables.
How do I set it?
In the form itself it looks like this:
I know that there is no form-tag, I wanted to ask how to combine this form with the saveform()-function as the trigger.
But what does it exactly do? In form.php there are a few lines e.g
Code:
$this->product_name_input = "data[product][product_name]";
$this->product_url_input = "data[product][product_url]";
It would be great if someone could explain how it works and what happens to the $this->product.. Variables.
How do I set it?
In the form itself it looks like this:
Code:
<div class="availability"><u>Verfügbarkeit</u><br /><br />
<input type="checkbox" name ="nl" value="newlabel" /> Neu, versiegelt <br />
<input type="checkbox" name ="n" value="newopened" /> Neu, in offener Originalverpackung <br />
<input type="checkbox" name ="u" value="used" /> Gebraucht <br />
</div>
I know that there is no form-tag, I wanted to ask how to combine this form with the saveform()-function as the trigger.
Please Log in or Create an account to join the conversation.
13 years 5 months ago #97069
by nicolas
Replied by nicolas on topic Insert datas to db via the backend (form.php)
The form tag is in the "form" view file.
Suppose that you have a text input, it should be:
and the rest will be automatic.
Suppose that you have a text input, it should be:
Code:
<input type="text" name ="data[product][column_name]" value="<?php echo @$this->element->column_name; ?>" />
The following user(s) said Thank You: Storm15
Please Log in or Create an account to join the conversation.
Time to create page: 0.192 seconds