[FLOW3-general] need help with f:form.select
"Christian Müller (FLOW3 Team)"
christian.mueller at typo3.org
Thu May 3 10:23:04 CEST 2012
Hi Wasko,
I think you have a minor misconception in your approach. Either you
directly accept the book in your listAction as it is now (and is the
recommended way) or you accept the idnr, which is I guess a string or
integer. I would go for accepting the book as your listAction already
shows. What I don't see are the proper annotations for your action,
those are needed. If you have them, your form should work this way:
<f:if condition="{books}">
<f:form action="detail">
<label for="book">Book</label><br />
<f:form.select name="book" options="{books}"
optionLabelField="name" id="book" sortByOptionLabel="true" /><br />
<f:form.submit value="Show" />
</f:form>
</f:if>
Because you actually just want to select one of your books and don't
edit any book you can directly use the name argument of the select
viewhelper, because your form doesn't deal with editing an object. This
way the selected book (UUID) will be given to the detailAction.
Cheers,
Christian
On 02/05/12 16:29, Wasko Jugovic wrote:
> Hi,
>
> As FLOW3 newbie I fail at this exercise:
> Index.html shows a form containing a drop-down list to select a book. That
> works for me. After form submission List.html should show a book's details
> (author, year....)
> What's the right syntax in "arguments" for passing the selected item's
> identifier from f:form:select to the listAction?
>
> My attempts end up with:
> "The requested URL's length exceeds the capacity limit for this server" ,
> when using {books: books}, because all identifiers and not only the selected
> one is passed ,
> "Required argument 'book' is not set" by using {books: books.idnr}
>
> My indexAction
>
> public function indexAction() {
> $this->view->assign('books', $this->bookRepository->findAll());
> ....
> ------------------
>
> My Index.html
>
> <f:if condition="{books}">
> <f:form action="detail" arguments="{????}" name="books">
> <label for="idnr">Book</label><br />
> <f:form.select property="idnr" options="{books}"
> optionLabelField="name" id="idnr" sortByOptionLabel="true" /><br />
> <f:form.submit value="Show" />
> </f:form>
> </f:if>
>
> --------------
>
> My listAction
>
> public function listAction(Book $book) {
> $this->view->assign('bookdetail',
> $this->bookRepository->findByIdentifyer($book));
> }
>
> Thanks!
>
>
--
Christian Mueller
TYPO3 Core Team
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the FLOW3-general
mailing list