phplaravel-5dms

Invalid processed submission: expecting value for field 'field_name' to be of type string, null given


I have a ObjectValue type class as Test

const FIELD_NAME = 'fieldName';

/**
 * @var string
 */
public $fieldName;
public function __construct($fieldName)
{
    $this->fieldName = $fieldName;
    parent::__construct();

}
protected function define(ClassDefinition $class)
{
    $class->property($this->fieldName)->asString();
}

and corresponding Mapper class

class TestMapper extends IndependentValueObjectMapper

{

protected function define(MapperDefinition $map)
{
    $map->type(Test::class);

    $map->property(Test::FIELD_NAME)->to('field_name')->asVarchar(255);
}

}

Migrated same to dms. When I try to add the field_name and save, it gives an error as follows

Invalid processed submission: expecting value for field 'field_name' to be of type string, null given (View: \dms-org\web.laravel\resources\views\components\form\staged-form.blade.php)

I'm not giving null, Its an string that I'm adding


Solution

  • I think you are playing around Entities with constructor !

    Could you please put the parent constructor call on first line

    public function __construct($fieldName)
    {
        parent::__construct();
    
        $this->fieldName = $fieldName;
    
    }
    

    This will ensure that if you call any value on your constructor, the parent class has already been set up correctly.

    I am not sure in your case ...

    Ignore me if i am wrong

    Thanks / Good luck!! :)