Skip to content

Commit

Permalink
Add missing form fields config
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Jan 13, 2016
1 parent c192ae4 commit 9f65924
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 8 deletions.
27 changes: 27 additions & 0 deletions src/Dvlpp/Sharp/Config/FormFields/SharpHiddenFormFieldConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Dvlpp\Sharp\Config\FormFields;

use Dvlpp\Sharp\Config\SharpFormFieldConfig;

class SharpHiddenFormFieldConfig extends SharpFormFieldConfig
{
/**
* @param string $key
* @return static
*/
public static function create($key)
{
$instance = new static;
$instance->key = $key;

$instance->label = "";

return $instance;
}

public function type()
{
return "hidden";
}
}
27 changes: 27 additions & 0 deletions src/Dvlpp/Sharp/Config/FormFields/SharpPasswordFormFieldConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Dvlpp\Sharp\Config\FormFields;

use Dvlpp\Sharp\Config\SharpFormFieldConfig;

class SharpPasswordFormFieldConfig extends SharpFormFieldConfig
{
/**
* @param string $key
* @return static
*/
public static function create($key)
{
$instance = new static;
$instance->key = $key;

$instance->label = "";

return $instance;
}

public function type()
{
return "password";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Dvlpp\Sharp\Config\FormFields;

use Dvlpp\Sharp\Config\SharpFormFieldConfig;

class SharpRefSublistItemFormFieldConfig extends SharpFormFieldConfig
{
/**
* @var string
*/
protected $repository;

/**
* @var string
*/
protected $linkedRefField;

/**
* @var string
*/
protected $refListKey;

/**
* @param string $key
* @param string $repository
* @param string $linkedRefField
* @param string $refListKey
* @return static
*/
public static function create($key, $repository, $linkedRefField, $refListKey)
{
$instance = new static;
$instance->key = $key;
$instance->repository = $repository;
$instance->linkedRefField = $linkedRefField;
$instance->refListKey = $refListKey;

$instance->label = "";

return $instance;
}

public function type()
{
return "ref";
}

/**
* @return string
*/
public function repository()
{
return $this->repository;
}

/**
* @return string
*/
public function linkedRefField()
{
return $this->linkedRefField;
}

/**
* @return string
*/
public function refListKey()
{
return $this->refListKey;
}

}
4 changes: 3 additions & 1 deletion src/Dvlpp/Sharp/Form/Fields/HiddenField.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Dvlpp\Sharp\Form\Fields;
<?php

namespace Dvlpp\Sharp\Form\Fields;

/**
* A simple hidden input element.
Expand Down
4 changes: 3 additions & 1 deletion src/Dvlpp/Sharp/Form/Fields/PasswordField.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Dvlpp\Sharp\Form\Fields;
<?php

namespace Dvlpp\Sharp\Form\Fields;

/**
* A password input field.
Expand Down
13 changes: 8 additions & 5 deletions src/Dvlpp/Sharp/Form/Fields/RefSublistItemField.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Dvlpp\Sharp\Form\Fields;
<?php

namespace Dvlpp\Sharp\Form\Fields;

use Dvlpp\Sharp\Exceptions\MandatoryClassNotFoundException;
use Dvlpp\Sharp\Exceptions\MandatoryMethodNotFoundException;
Expand All @@ -22,17 +24,18 @@ class RefSublistItemField extends AbstractSharpField {
*/
function make()
{
$this->_checkMandatoryAttributes(["repository","linked_ref_field","ref_list_id"]);
$this->_checkMandatoryAttributes(["repository","linkedRefField","refListKey"]);

$repoName = $this->field->repository();

$repoName = $this->field->repository;
if(class_exists($repoName) || interface_exists($repoName)) {
$repo = app($repoName);

$this->addClass("sharp-refSublistItem", true);
$this->addData("linked_ref_field", $this->field->linked_ref_field);
$this->addData("linked_ref_field", $this->field->linkedRefField());

if(method_exists($repo, "formListForSublist")) {
$allValues = $repo->formListForSublist($this->field->ref_list_id, $this->instance);
$allValues = $repo->formListForSublist($this->field->refListKey(), $this->instance);

// We have to manually handle the initial value, in JS code,
// because of linked selects
Expand Down
4 changes: 3 additions & 1 deletion src/Dvlpp/Sharp/Form/Fields/TextField.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Dvlpp\Sharp\Form\Fields;
<?php

namespace Dvlpp\Sharp\Form\Fields;

/**
* A simple text input element.
Expand Down

0 comments on commit 9f65924

Please sign in to comment.