I'm trying to develop my first component for Joomla 3.x.
In the backend almost everything works fine but in the frontend there is one big problem:
The frontend shows a view called "items". If a user picks an item from this list he gets redirected to the view "item" (detail-view: index.php?option=com_mycomponent&view=item&id=4).
If the user wants to create a comment on this item, he has to click a button, which redirects the user to the comment-view (index.php?option=com_mycomponent&view=comment&id=4).
The data the user enters in this field have to be saved to the database, using the table, which is located in the backend.
That works already: I'm able to save the comment itself, the user-id, the timestamp etc. but I'm not able to save the given ID, which allows me to assign the comment to the item.
I thought I could just get the URL-Param "ID" by using this in my frontend-controller, which saves the data to the database:
$item_id = JRequest::getVar('id');
But this does never have a value. What do I have to use here?
I created a comment.xml like this:
<form>
<fieldset name="comment">
<field name="id" type="hidden"/>
<field name="item_id" type="hidden"/>
<field name="firstname" type="text" size="40"
class="inputbox"
required="true"
default=""
autocomplete="off"
label="COM_BESTIA_BESTIA_TYPEDETAILS_INFO"
description="COM_BESTIA_BESTIA_TYPEDETAILS_DESC"/>
<field name="lastname" type="text" size="40"
class="inputbox"
required="true"
default=""
autocomplete="off"
label="COM_BESTIA_BESTIA_TYPEDETAILS_INFO"
description="COM_BESTIA_BESTIA_TYPEDETAILS_DESC"/>
</fieldset>
</form>
In my default.php (view) I'm setting the value:
$item_id = JFactory::getApplication()->input->getInt('item_id');
$mod_item_id = $this->form->setValue('item_id', null, $item_id);
That works so far :)
Well, now I want to split up the comment.xml into different fieldsets, for example:
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset name="comment">
<field name="id" type="hidden"/>
<field name="item_id" type="hidden"/>
</fieldset>
<fieldset name="personal-data">
<field name="firstname" type="text" size="40"
class="inputbox"
required="true"
default=""
autocomplete="off"
label="COM_BESTIA_BESTIA_TYPEDETAILS_INFO"
description="COM_BESTIA_BESTIA_TYPEDETAILS_INFO_DESC"/>
<field name="lastname" type="text" size="40"
class="inputbox"
required="true"
default=""
autocomplete="off"
label="COM_BESTIA_BESTIA_TYPEDETAILS_INFO"
description="COM_BESTIA_BESTIA_TYPEDETAILS_INFO_DESC"/>
</fieldset>
</form>
But now it doesn't work at all: The item_id is not set in the controller and the fields, which are located in the fields are not written into the database.
What is the problem here?
thank you for your response :)
Well, I know that I don't have to use a seperate fieldset for the item_id and id-hidden-fields, but I want to structurize my view and load the fieldsets seperately on different positions.
It's Joomla 3.2.2.
I'll have a look at the debugging, thanks so far. If I have any further questions I'd like to post it here, too (your postings were very informative and friendly :) ).
Thanks :)