[TYPO3-english] add, edit Tx_RoqNewsevent_Domain_Model_Event from frontend

Richard Davies richard at ocular.co.nz
Mon Feb 23 21:50:22 CET 2015


Hi Vikram,

Add action:
Your action has a parameter of "$eventItem". In your List template there is
no 'eventItem' mentioned in your f:link.action. Typo3 is looking for that
param but can't find it.
It isn't completely clear what you want your 'add' to do, but hopefully
this should help:
Add a form instead of the link. Then in your action you can save it to the
database:
So where you have

> <f:link.action action="add" controller="Events" >Add Event</f:link.action>
>
You could have a form similar to:

> <f:form name="eventItem" action="add" object="{event}" controller="Events"
> enctype="multipart/form-data">
>                 <f:form.textfield id="title" property="title" size="46" />
>                 <f:form.submit value="Add Event" />
>             </f:form>
>

In your action you will then need:

> public function addAction(Tx_RoqNewsevent_Doma
> in_Model_Event $eventItem) {
>                 $this->eventRepository->add($eventItem); //add it to the
> database
>
                //code here should send to list view or edit view
>
        }
>

At the end of the event you can send the user to the list view or another
view using a forward or redirect.


In your edit form you have

> objectName"{eventItem}"
>
missing the = between them

> objectName = "{eventItem}"
>


I'm not 100% sure if that is the reason why your edit isn't working - there
should be more debug information.
If you want your edit to load the information the field it maps to, add the
value:

> <f:form.textfield id="title" property="title" size="46" />
>
to

> <f:form.textfield id="title" value="{title}" property="title" size="46" />
>

Hopefully that helps.
Richard

On 23 February 2015 at 18:46, Vikram <vikram at fivee.in> wrote:

> Hi Richard,
>
> Thanks for responding .. here is the fluid template code:
> http://www.codeshare.io/N3uU6
>
> regards
> Vikram
>
>
> On 02/23/2015 02:32 AM, Richard Davies wrote:
>
>> Hey Vikram,
>>
>> Can you show us the section of the fluid template in which you create the
>> link / form to the edit action?
>>
>> Richard
>>
>> On 22 February 2015 at 01:02, Vikram <vikram at fivee.in> wrote:
>>
>>  Hi,
>>>
>>> I am trying to edit and add Tx_RoqNewsevent_Domain_Model_Event records
>>> from frontend.
>>>
>>> Tx_RoqNewsevent_Domain_Model_Event extends tx_news and it adds fews
>>> fields.
>>>
>>> While listing works fine but
>>>
>>> But in my add action I get error:
>>>   Required argument "eventItem" is not set
>>>
>>>
>>> In edit action I get:
>>> An error occurred while trying to call ..Controller\EventsController-
>>>
>>>> editAction().
>>>>
>>>
>>> Any suggestion where i must look?
>>>
>>> The code works fine if i use news objects. but then i am not able to set
>>> values to fields added by Roq_Newsevent
>>>
>>> ---my controller code---
>>> <?php
>>> namespace T3IN\T3inEvents\Controller;
>>>
>>> /**
>>>   * EventsController
>>>   */
>>> class EventsController extends \TYPO3\CMS\Extbase\Mvc\
>>> Controller\ActionController
>>> {
>>>
>>>          /**
>>>           * eventRepository
>>>           *
>>>           * @var Tx_RoqNewsevent_Domain_Repository_EventRepository
>>>           * @inject
>>>           */
>>>          protected $eventRepository;
>>>
>>>          /**
>>>           * action list
>>>           * @return void
>>>           */
>>>          public function listAction() {
>>>                  $eventRecords = $this->eventRepository->findAll();
>>>                  $this->view->assign('eventRecords', $eventRecords);
>>>          }
>>>
>>>
>>>          /**
>>>           * action edit
>>>           * @param Tx_RoqNewsevent_Domain_Model_Event $eventItem
>>>           * @return string
>>>           */
>>>          public function editAction(Tx_RoqNewsevent_Domain_Model_Event
>>> $eventItem) {
>>>                  $this->view->assign('eventItem', $eventItem);
>>>
>>>          }
>>>
>>>          /**
>>>           * action add
>>>           * @param Tx_RoqNewsevent_Domain_Model_Event $eventItem
>>>           * @return string
>>>           */
>>>          public function addAction(Tx_RoqNewsevent_Domain_Model_Event
>>> $eventItem) {
>>>                  $this->view->assign('eventItem', $eventItem);
>>>          }
>>>
>>> }
>>>
>>>
>>> --
>>> regards
>>> Vikram Mandal
>>> --
>>> FiveE Technologies.
>>> http://FiveEtechnologies.com
>>> _______________________________________________
>>> TYPO3-english mailing list
>>> TYPO3-english at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
>>>
>>>
>
> --
> regards
> Vikram Mandal
> --
> FiveE Technologies.
> http://FiveEtechnologies.com
>
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
>


More information about the TYPO3-english mailing list