Skip to content

Commit

Permalink
Improved admin create form
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaplet committed Apr 10, 2024
1 parent 1f258f7 commit f4c7979
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Recipe/AdminRecipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Megio\Collection\ReadBuilder\ReadBuilder;
use Megio\Collection\RecipeRequest;
use Megio\Collection\WriteBuilder\Field\Base\EmptyValue;
use Megio\Collection\WriteBuilder\WriteBuilder;
use Megio\Collection\WriteBuilder\Field\EmailField;
use Megio\Collection\WriteBuilder\Field\PasswordField;
Expand Down Expand Up @@ -37,16 +38,22 @@ public function readAll(ReadBuilder $builder, RecipeRequest $request): ReadBuild

public function create(WriteBuilder $builder, RecipeRequest $request): WriteBuilder
{
//$builder->
return $builder
->add(new EmailField('email', 'E-mail', [new RequiredRule()]))
->add(new PasswordField('password', 'Password', [new RequiredRule()]));
}

public function update(WriteBuilder $builder, RecipeRequest $request): WriteBuilder
{
$pwf = new PasswordField(name: 'password', label: 'Heslo');

// Do not show password on form rendering
if ($request->isFormRendering()) {
$pwf->setValue(new EmptyValue());
}

return $builder
->add(new EmailField('email', 'E-mail', [new RequiredRule()]))
->add(new PasswordField('password', 'Password'));
->add($pwf);
}
}

0 comments on commit f4c7979

Please sign in to comment.