/** @test */ function it_creates_a_form_with_fields() { $builder = $this->getBuilder(); $this->assertFileNotExists($builder->getClassFilePath('project')); $builder->build('project', Collection::make([NodeField::create(['name' => 'description', 'type' => 'text', 'description' => 'Some hints', 'label' => 'Project Description', 'rules' => '\'required|max:5000\'', 'default_value' => '\'Texty text\'', 'position' => 1, 'search_priority' => 10]), NodeField::create(['name' => 'type', 'type' => 'select', 'description' => 'Some hints for type', 'label' => 'Project Type', 'position' => 2, 'options' => "'choices' => [1 => 'Housing', 2 => 'Cultural'], 'selected' => function(\$data) {return 1;}, 'empty_value' => '---no type---'", 'search_priority' => 0])])); $this->assertFileExists($builder->getClassFilePath('project')); }
/** * Update the specified resource in storage. * * @param BuilderService $builderService * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(BuilderService $builderService, Request $request, $id) { $this->authorize('EDIT_NODETYPES'); $nodeField = NodeField::findOrFail($id); $this->validateEditForm($request); $nodeField->update($request->all()); $builderService->buildForm($nodeField->nodeType); $this->notify('nodefields.edited'); return redirect()->route('reactor.nodefields.edit', $id); }
protected function getNodeField($attributes = []) { $attributes = !empty($attributes) ? $attributes : ['name' => 'area', 'label' => 'Area', 'description' => '', 'type' => 'text', 'position' => 1.0, 'search_priority' => 0]; return NodeField::create($attributes); }