[TYPO3-mvc] Extension Builder and realtions
Anja Leichsenring
aleichsenring at ab-softlab.de
Sun Jun 23 10:35:18 CEST 2013
Hi Sven,
inside your controller, you need to retrieve all the agencies from the
persistence and pass them to the view. Then you can create there a
selectfield. I give an (untested) example:
Controller:
namespace Vendor\Extension\Controller;
class CustomerController ... {
/**
* @var \Vendor\Extension\Domain\Repository\CustomerRepository
* @inject
*/
protected customerRepository;
/**
* @var \Vendor\Extension\Domain\Repository\AgencyRepository
* @inject
*/
protected agencyRepository;
public function newAction() {
$agencies = $this->agencyRepository->findAll();
$this->view->assign('agencies', $agencies);
}
}
Template Customer/New.html:
<f:form action="create" object="customer">
...
<f:form.select property="agency" options="{agencies}"
prependOptionLabel="please select" />
...
</f:form>
I hope that helps
Anja
On 06/23/2013 10:11 AM, Sven Hofacker wrote:
> Hi there,
>
> i will build an Extension with the Extension Builder 6.
> I create 2 Models, Model 1 = Agency and Model 2 = Customer
> Model 2 has a Relation to Model 1 (Agency)
>
> I create 3 Agencys in the Backend. If i create a Customer in the Backend, i
> see the three Agencys in the select field and i can select one of them.
> So the Agency will get a Customer ;-)
>
> I build a Frontend Plugin also. I can create the Agencys, but if i try to
> create a customer, then there is no select field!
> What must i write in the Controller or New.html File to get the Agency
> select field?
>
> I will hope, you can understand my Problem . sry for my english ..
>
> Sven Hofacker (DE)
>
>
More information about the TYPO3-project-typo3v4mvc
mailing list