Skip to content

Commit

Permalink
Rename to prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed May 23, 2017
1 parent 2fc5375 commit 2e470f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public function __construct(Group $group, array $settings)
*/
public function setKey(string $key)
{
$group = str_replace('group_', '', $this->group->getKey());
$prefix = str_replace('group_', '', $this->group->getKey());

$name = Str::snake($key);

$key = sprintf('field_%s_%s', $group, $name);
$key = sprintf('field_%s_%s', $prefix, $name);

if (in_array($key, self::$keys)) {
throw new InvalidArgumentException("The field key [$key] is not unique.");
Expand Down Expand Up @@ -112,15 +112,15 @@ public function getConditionalLogic(): array
{
$conditionalLogic = [];

$groupKey = str_replace('group_', '', $this->group->getKey());
$prefix = str_replace('group_', '', $this->group->getKey());

foreach ($this->settings['conditional_logic'] as $rules) {
$group = [];

foreach ($rules as $rule) {
$name = Str::snake($rule['name']);

$field = sprintf('field_%s_%s', $groupKey, $name);
$field = sprintf('field_%s_%s', $prefix, $name);

$rule = [
'field' => $field,
Expand Down

0 comments on commit 2e470f6

Please sign in to comment.