-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix missing require option in configuration form, fix #79
- Loading branch information
Showing
13 changed files
with
1,297 additions
and
20 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
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,12 @@ | ||
{% block PackageConstraintType_row %} | ||
<div class="clearfix"> | ||
{{ form_errors(form) }} | ||
{{ form_widget(form) }} | ||
</div> | ||
{% endblock %} | ||
|
||
{% block PackageConstraintType_widget %} | ||
<div class="col-sm-6">{{ form_widget(form.package) }} {{ form_errors(form.package) }}</div> | ||
<div class="col-sm-4">{{ form_widget(form.constraint) }} {{ form_errors(form.constraint) }}</div> | ||
<div class="col-sm-2 {{ form.parent.vars.id }}-collection-actions"></div> | ||
{% endblock %} |
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,33 @@ | ||
{# | ||
# jquery.collection.html.twig | ||
# | ||
# Adds the following html attributes to the root node of your collection fields: | ||
# | ||
# - data-prototype-name: placeholder used in the prototype to replace element indexes on the collection | ||
# - data-allow-add: if set to false, plugin will automatically set allow_add option to false | ||
# - data-allow-delete: if set to false, plugin will automatically set allow_remove option to false | ||
# - data-name-prefix: contains the collection's prefix used in descendant field names | ||
# | ||
# Those information let you configure the plugin options automatically. | ||
# | ||
# If you are already using a form theme, you can use both by using: | ||
# {% | ||
# form_theme myForm | ||
# 'FuzAppBundle::my-form-theme.html.twig' | ||
# 'FuzAppBundle::jquery.collection.html.twig' | ||
# ... | ||
# %} | ||
#} | ||
|
||
{% block collection_widget %} | ||
{% spaceless %} | ||
{% if prototype is defined %} | ||
{% set attr = attr|merge({'data-prototype': form_row(prototype)}) %} | ||
{% set attr = attr|merge({'data-prototype-name': prototype.vars.name}) %} | ||
{% endif %} | ||
{% set attr = attr|merge({'data-allow-add': allow_add ? 1 : 0}) %} | ||
{% set attr = attr|merge({'data-allow-remove': allow_delete ? 1 : 0 }) %} | ||
{% set attr = attr|merge({'data-name-prefix': full_name}) %} | ||
{{ block('form_widget') }} | ||
{% endspaceless %} | ||
{% endblock collection_widget %} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,55 @@ | ||
<?php | ||
|
||
namespace Playbloom\Satisfy\Form\Type; | ||
|
||
use Playbloom\Satisfy\Model\PackageConstraint; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class PackageConstraintType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add( | ||
'package', | ||
TextType::class, | ||
[ | ||
'required' => true, | ||
'empty_data' => '', | ||
'constraints' => [ | ||
new Assert\NotBlank(), | ||
], | ||
'attr' => [ | ||
'placeholder' => 'Package name', | ||
], | ||
] | ||
) | ||
->add('constraint', TextType::class, [ | ||
'required' => true, | ||
'empty_data' => '', | ||
'constraints' => [ | ||
new Assert\NotBlank(), | ||
], | ||
'attr' => [ | ||
'placeholder' => 'Package version, i.e. ^1.0', | ||
], | ||
]); | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver) | ||
{ | ||
$resolver->setDefaults([ | ||
'data_class' => PackageConstraint::class, | ||
'empty_data' => new PackageConstraint('', ''), | ||
]); | ||
} | ||
|
||
public function getBlockPrefix() | ||
{ | ||
return 'PackageConstraintType'; | ||
} | ||
} |
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
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,48 @@ | ||
<?php | ||
|
||
namespace Playbloom\Satisfy\Model; | ||
|
||
class PackageConstraint | ||
{ | ||
/** @var string */ | ||
private $package; | ||
|
||
/** @var string */ | ||
private $constraint; | ||
|
||
public function __construct(string $package, string $constraint) | ||
{ | ||
$this->package = $package; | ||
$this->constraint = $constraint; | ||
} | ||
|
||
public function getPackage(): string | ||
{ | ||
return $this->package; | ||
} | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function setPackage(string $package) | ||
{ | ||
$this->package = $package; | ||
|
||
return $this; | ||
} | ||
|
||
public function getConstraint(): string | ||
{ | ||
return $this->constraint; | ||
} | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function setConstraint(string $constraint) | ||
{ | ||
$this->constraint = $constraint; | ||
|
||
return $this; | ||
} | ||
} |
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
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
Oops, something went wrong.