-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chihiro-adachi
committed
Apr 13, 2017
1 parent
65be318
commit 7e5d698
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
namespace Acme\Controller; | ||
|
||
use Eccube\Application; | ||
use Eccube\Entity\BaseInfo; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class EntityFormController | ||
{ | ||
/** | ||
* @Route("/entity-form") | ||
*/ | ||
public function index(Application $app, Request $request) | ||
{ | ||
$BaseInfo = new BaseInfo(); | ||
|
||
$builder = $app->form( | ||
$BaseInfo, | ||
[ | ||
'data_class' => BaseInfo::class, | ||
] | ||
); | ||
|
||
$form = $builder->getForm(); | ||
$form->add('submit', SubmitType::class); | ||
|
||
$form->handleRequest($request); | ||
if ($form->isSubmitted() && $form->isValid()) { | ||
// do stuff. | ||
} | ||
|
||
$template = " | ||
{{ form_start(form) }} | ||
{{ form_row(form) }} | ||
{{ form_end(form) }} | ||
"; | ||
|
||
$params = ['form' => $form->createView()]; | ||
|
||
return $app['twig'] | ||
->createTemplate($template) | ||
->render($params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Acme\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Eccube\Annotation\EntityExt; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
/** | ||
* @EntityExt(target="Eccube\Entity\BaseInfo") | ||
*/ | ||
trait BaseInfoTrait | ||
{ | ||
/** | ||
* @ORM\Column(name="company_name_vn", type="string", length=255, nullable=true, options={"eccube_form_render":true}) | ||
* @Assert\NotBlank(message="にゅうりょくしてくださいね!!!") | ||
*/ | ||
public $company_name_vn; | ||
} |