예제 #1
2
 /**
  *
  * @return \Kris\LaravelFormBuilder\Form
  */
 private function formUserDetail()
 {
     $formUserDetail = $this->formBuilder->create('App\\Http\\Forms\\UserDetailForm', ['method' => 'PUT', 'url' => route('user.details.store'), 'model' => $this->userDetail]);
     $formUserDetail->modify('avatar', 'file', ['value' => '']);
     $formUserDetail->add('submit', 'submit', ['label' => 'Change your user details', 'attr' => ['class' => 'btn btn-primary btn-block']]);
     return $formUserDetail;
 }
 /**
  * Display the specified Blacklist Domain.
  *
  * @param BlacklistDomain $blacklistDomain
  * @param FormBuilder $formBuilder
  * @return Response
  */
 public function show(BlacklistDomain $blacklistDomain, FormBuilder $formBuilder)
 {
     if ($blacklistDomain->zone_id) {
         $zoneName = $blacklistDomain->zone->name;
     } else {
         $zoneName = trans('admin.blacklist_domain.global');
     }
     $form = $formBuilder->create('Admin\\BlacklistDomainForm', ['model' => $blacklistDomain])->add('zone_name', 'text', ['label' => trans('admin.blacklist_domain.field_zone_name'), 'default_value' => $zoneName, 'attr' => ['disabled' => 'disabled']]);
     return view('admin.blacklist-domain.show', compact('form'));
 }
 public function edit($id, FormBuilder $formBuilder)
 {
     $result = IndustryType::findOrFail($id);
     $form = $formBuilder->create('employment_bank\\Forms\\IndustryTypeForm', ['method' => 'PUT', 'model' => $result, 'url' => route($this->route . 'update', $id)])->remove('save');
     //->setData('market_values', $markets);
     return view($this->content . 'edit', compact('form'));
 }
 /**
  * Show the form for editing the specified article.
  *
  * @param Article $article
  * @param FormBuilder $formBuilder
  * @return Response
  */
 public function edit(Article $article, FormBuilder $formBuilder)
 {
     $language = Session::get('current_lang');
     $categories = $language->categories->lists('title', 'id')->all();
     $form = $formBuilder->create('App\\Forms\\ArticlesForm', ['method' => 'PATCH', 'url' => route('admin.article.update', ['id' => $article->id]), 'model' => $article], $categories);
     return view('admin.articles.edit', compact('form', 'article'));
 }
 public function edit($id, Request $request, FormBuilder $formBuilder)
 {
     $permission = $this->permission->find($id);
     $form = $formBuilder->create('App\\Forms\\PermissionForm', ['model' => $permission, 'method' => 'PUT', 'url' => route('admin.permissions.update', $id)]);
     $script = 'js/backend/access/permissions/dependencies/script.js';
     return view($request->ajax() ? 'layout.partials.ajax_form' : 'layout.partials.form', compact('form', 'script'));
 }
 public function store(FormBuilder $formBuilder)
 {
     $form = $formBuilder->create('App\\Forms\\SongForm');
     if (!$form->isValid()) {
         return redirect()->back()->withErrors($form->getErrors())->withInput();
     }
     // Do saving and other things...
 }
 /** @test */
 public function it_appends_default_namespace_from_config_on_building()
 {
     $form = new LaravelFormBuilderTest\Forms\NamespacedDummyForm();
     $config = $this->config;
     $config['default_namespace'] = 'LaravelFormBuilderTest\\Forms';
     $formHelper = new FormHelper($this->view, $this->translator, $config);
     $formBuilder = new FormBuilder($this->app, $formHelper);
     $formBuilder->create('NamespacedDummyForm');
 }
 public function create(FormBuilder $formBuilder, $groupId = null)
 {
     $orgModel = [];
     if (null !== $groupId) {
         $orgModel = $this->orgGroupManager->getModelForUpdate($groupId);
     }
     $form = $formBuilder->create('App\\SuperAdmin\\Forms\\OrganizationGroup', ['method' => null !== $groupId ? 'PUT' : 'POST', 'url' => null !== $groupId ? route('admin.edit-group', [$groupId]) : route('admin.create-organization-group'), 'model' => $groupId ? $orgModel : null]);
     return view('superAdmin.groupOrganization.create', compact('form', 'groupId'));
 }
예제 #9
0
 /**
  * Render the form to $view when edit a record
  *
  * @param FormBuilder $formBuilder
  * @param Model $model
  * @param string $formName
  * @param string $view
  * @param string $modelName
  * @return Response
  */
 protected function defaultEdit(FormBuilder $formBuilder, Model $model, $formName, $view, $modelName = null)
 {
     $form = $formBuilder->create($formName, ['method' => 'PUT', 'url' => $this->route(explode('.', $view)[1] . '.update', ['id' => $model->id]), 'model' => $model]);
     if ($modelName) {
         return view($view, ['form' => $form, $modelName => $model]);
     } else {
         return view($view, compact('form'));
     }
 }
예제 #10
0
 public function store(FormBuilder $formBuilder, Request $request)
 {
     $form = $formBuilder->create(AdvertsForm::class);
     if (!$form->isValid()) {
         return redirect()->back()->withErrors($form->getErrors())->withInput();
     }
     Adverts::create($request->all());
     return redirect()->route('advert.index');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request, FormBuilder $formBuilder, $page = null)
 {
     $applicationBySubjectList = new ApplicationBySubjectList($request, $this->main_page, $page);
     $keys = $applicationBySubjectList->getKeys();
     $data_arr = $applicationBySubjectList->getDataArr();
     $paginationForm = $applicationBySubjectList->getPaginationForm();
     $filter = session('application_by_subject_filter');
     $form_filter = $formBuilder->create('App\\Filters\\ApplicationBySubjectFilter', ['method' => 'PATCH', 'action' => ['ApplicationBySubjectController@index'], 'model' => $filter, 'class' => 'form-inline']);
     return view('list', ['controller' => 'ApplicationBySubjectController', 'data_arr' => $data_arr, 'keys' => $keys, 'perm_path' => $this->main_page, 'path' => $this->main_page, 'title' => 'APPLICATION_BY_SUBJECTS', 'filter' => $form_filter, 'pagination' => $paginationForm, 'add' => false, 'additional_info' => false, 'back' => false, 'parent_table_id' => false, 'edit' => false, 'delete' => false, 'modal' => true]);
 }
예제 #12
0
 public function store(FormBuilder $formBuilder, Request $request)
 {
     $form = $formBuilder->create(StatesForm::class);
     // It will automatically use current request, get the rules, and do the validation
     if (!$form->isValid()) {
         return redirect()->back()->withErrors($form->getErrors())->withInput();
     }
     States::create($request->all());
     return redirect()->route('state.index');
 }
예제 #13
0
 /**
  * Show the form required by an ajax request.
  *
  * @param             $parent
  * @param FormBuilder $formBuilder
  *
  * @return \Illuminate\Http\Response
  */
 public function add(FormBuilder $formBuilder, $parent)
 {
     $articleComment = ArticleComment::whereId($parent)->get(['article_id'])->first();
     $slug = Article::whereId($articleComment->article_id)->get(['slug'])->first();
     $form = $formBuilder->create('\\App\\Http\\Forms\\ArticleCommentForm', ['method' => 'POST', 'id' => 'article_comment_form', 'url' => route('articles.comment.store')]);
     $form->add('slug', 'hidden', ['value' => $slug->slug, 'attr' => ['id' => 'slug']]);
     $form->add('parent_id', 'hidden', ['value' => $parent, 'attr' => ['id' => 'parent_id']]);
     $form->add('save', 'submit', ['label' => 'Add your comment']);
     return response()->view('articles.ajax_article_comment_show', compact('form'));
 }
예제 #14
0
 public function update($id, FormBuilder $formBuilder, Request $request)
 {
     $good = Goods::findOrFail($id);
     $form = $formBuilder->create(GoodsForm::class);
     // It will automatically use current request, get the rules, and do the validation
     if (!$form->isValid()) {
         return redirect()->back()->withErrors($form->getErrors())->withInput();
     }
     $good->update($request->all());
     return redirect()->route('good.index');
 }
예제 #15
0
 /**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function contactUs()
 {
     if (Auth::guest()) {
         $user = new User();
     } else {
         $user = Auth::user();
     }
     $form = $this->formBuilder->create('App\\Http\\Forms\\ContactUsForm', ['method' => 'POST', 'url' => route('home.contact'), 'model' => $user]);
     $form->add('send', 'submit', ['label' => 'Send this message', 'attr' => ['class' => 'btn btn-primary btn-block']]);
     return view('home.contact_us', compact('form'));
 }
예제 #16
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, FormBuilder $formBuilder)
 {
     $course_arr = [];
     $course = CourseQuery::create()->findPK($id);
     $course_arr = $course->toArray();
     $form = $formBuilder->create('App\\Forms\\CourseForm', ['method' => 'PATCH', 'action' => ['CourseController@update', $id], 'model' => $course_arr]);
     $form_name = 'COURSE';
     $action = 'EDIT_OBJ';
     $path = $this->main_page;
     session(['attribute' => \Lang::get('general.COURSE')]);
     return view('manage', compact('form', 'form_name', 'action', 'path'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, FormBuilder $formBuilder)
 {
     $professor_arr = [];
     $professor = ProfessorQuery::create()->findPK($id);
     $professor_arr = $professor->toArray();
     $form = $formBuilder->create('App\\Forms\\ProfessorForm', ['method' => 'PATCH', 'action' => ['ProfessorController@update', $id], 'model' => $professor_arr]);
     $form_name = 'PROFESSOR';
     $action = 'EDIT_OBJ';
     $path = $this->main_page;
     session(['attribute' => \Lang::get('general.PROFESSOR_OBJ')]);
     return view('manage', compact('form', 'form_name', 'action', 'path'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, FormBuilder $formBuilder)
 {
     $schoolYear_arr = [];
     $schoolYear = SchoolYearQuery::create()->findPK($id);
     $schoolYear_arr = $schoolYear->toArray();
     $form = $formBuilder->create('App\\Forms\\SchoolYearForm', ['method' => 'PATCH', 'action' => ['SchoolYearController@update', $id], 'model' => $schoolYear_arr]);
     $form_name = 'SCHOOL_YEAR';
     $action = 'EDIT_OBJ';
     $path = $this->main_page;
     session(['attribute' => \Lang::get('general.SCHOOL_YEAR_OBJ')]);
     return view('manage', compact('form', 'form_name', 'action', 'path'));
 }
 public function setUp()
 {
     parent::setUp();
     $this->view = $this->app['view'];
     $this->request = $this->app['request'];
     $this->request->setSession($this->app['session.store']);
     $this->validatorFactory = $this->app['validator'];
     $this->model = new TestModel();
     $this->config = (include __DIR__ . '/../src/config/config.php');
     $this->formHelper = new FormHelper($this->view, $this->config);
     $this->formBuilder = new FormBuilder($this->app, $this->formHelper);
     $this->plainForm = $this->formBuilder->plain();
 }
예제 #20
0
 public function setUp()
 {
     parent::setUp();
     $this->view = $this->app['view'];
     $this->request = $this->app['request'];
     $this->request->setSession($this->app['session.store']);
     $this->validatorFactory = $this->app['validator'];
     $this->model = Mockery::mock('Illuminate\\Database\\Eloquent\\Model');
     $this->config = (include __DIR__ . '/../src/config/config.php');
     $this->formHelper = new FormHelper($this->view, $this->request, $this->config);
     $this->formBuilder = new FormBuilder($this->app, $this->formHelper);
     $this->plainForm = $this->formBuilder->plain();
 }
예제 #21
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, FormBuilder $formBuilder)
 {
     $student_arr = [];
     $student = StudentQuery::create()->findPK($id);
     $student_arr = $student->toArray();
     $student_arr['IdentificationNumberOrig'] = $student->getIdentificationNumber();
     $student_arr['SchoolYearIdOrig'] = $student->getSchoolYearId();
     $form = $formBuilder->create('App\\Forms\\StudentForm', ['method' => 'PATCH', 'action' => ['StudentController@update', $id], 'model' => $student_arr]);
     $form_name = 'STUDENT';
     $action = 'EDIT_OBJ';
     $path = $this->main_page;
     session(['attribute' => \Lang::get('general.STUDENT_OBJ')]);
     return view('manage', compact('form', 'form_name', 'action', 'path'));
 }
예제 #22
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($period_id, $school_year_id, FormBuilder $formBuilder)
 {
     $period_arr = [];
     $period = PeriodSchoolYearQuery::create()->findPK([$period_id, $school_year_id]);
     $period_arr = $period->toArray();
     $period_arr['PeriodIdOrig'] = $period->getPeriodId();
     $period_arr['SchoolYearIdOrig'] = $period->getSchoolYearId();
     $form = $formBuilder->create('App\\Forms\\PeriodForm', ['method' => 'PATCH', 'action' => ['PeriodController@update', $period_id, $school_year_id], 'model' => $period_arr]);
     $form_name = 'PERIOD';
     $action = 'EDIT_OBJ';
     $path = $this->main_page;
     session(['attribute' => \Lang::get('general.PERIOD')]);
     return view('manage', compact('form', 'form_name', 'action', 'path'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($subject_id, $course_id, FormBuilder $formBuilder)
 {
     $study_program_arr = [];
     $study_program = StudyProgramQuery::create()->findPK([$subject_id, $course_id]);
     $study_program_arr = $study_program->toArray();
     $study_program_arr['SubjectIdOrig'] = $study_program->getSubjectId();
     $study_program_arr['CourseIdOrig'] = $study_program->getCourseId();
     $form = $formBuilder->create('App\\Forms\\StudyProgramForm', ['method' => 'PATCH', 'action' => ['StudyProgramController@update', $subject_id, $course_id], 'model' => $study_program_arr]);
     $form_name = 'STUDY_PROGRAM';
     $action = 'EDIT_OBJ';
     $path = $this->main_page;
     session(['attribute' => \Lang::get('general.STUDY_PROGRAM')]);
     return view('manage', compact('form', 'form_name', 'action', 'path'));
 }
예제 #24
0
    /**
     * Take another form and add it's fields directly to this form
     * @param mixed   $class        Form to merge
     * @param array   $options
     * @param boolean $modify
     * @return $this
     */
    public function compose($class, array $options = [], $modify = false)
    {
        $options['class'] = $class;

        // If we pass a ready made form just extract the fields
        if ($class instanceof Form) {
            $fields = $class->getFields();
        } elseif ($class instanceof Fields\ChildFormType) {
            $fields = $class->getForm()->getFields();
        } elseif (is_string($class)) {
            // If its a string of a class make it the usual way
            $options['model'] = $this->model;
            $options['name'] = $this->name;

            $form = $this->formBuilder->create($class, $options);
            $fields = $form->getFields();
        } else {
            throw new \InvalidArgumentException(
                "[{$class}] is invalid. Please provide either a full class name, Form or ChildFormType"
            );
        }

        foreach ($fields as $field) {
            $this->addField($field, $modify);
        }

        return $this;
    }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, FormBuilder $formBuilder)
 {
     $user_arr = [];
     $user = AdminUserQuery::create()->findPK($id);
     $user_arr = $user->toArray();
     $userCredentials = AdminUserCredentialQuery::create()->where('admin_user_id = ' . $id)->find();
     foreach ($userCredentials as $credential) {
         $credential_id = $credential->getAdminCredentialId();
         if ($credential->getPermRead() == 1) {
             $user_arr['Credentials'][$credential_id]['read'] = 'read';
         }
         if ($credential->getPermWrite() == 1) {
             $user_arr['Credentials'][$credential_id]['write'] = 'write';
         }
         if ($credential->getPermExec() == 1) {
             $user_arr['Credentials'][$credential_id]['exec'] = 'exec';
         }
     }
     $form = $formBuilder->create('App\\Forms\\AdminUserForm', ['method' => 'PATCH', 'action' => ['AdminUserController@update', $id], 'model' => $user_arr]);
     $form_name = 'USER';
     $action = 'EDIT_OBJ';
     $path = $this->main_page;
     $back = $this->main_page;
     session(['attribute' => \Lang::get('general.USER_OBJ')]);
     return view('manage', compact('form', 'form_name', 'action', 'path', 'back'));
 }
 /**
  * add new organization by superAdmin
  * @param FormBuilder $formBuilder
  * @param null        $orgId
  * @return \Illuminate\View\View
  */
 public function add(FormBuilder $formBuilder, $orgId = null)
 {
     $data = '{"default_field_groups":[{"title":"Title","description":"Description","activity_status":"Activity Status","activity_date":"Activity Date","participating_org":"Participating Org","recipient_county":"Recipient Country","location":"Location","sector":"Sector","budget":"Budget","transaction":"Transaction","document_ink":"Document Link"}]}';
     $model = json_decode($data, true);
     if ($orgId) {
         $organizationInfo = $this->adminManager->getOrganizationUserBYId($orgId);
         $settings = $this->settingsManager->getSettings($orgId);
         if ($settings) {
             $model['default_field_groups'] = $settings->default_field_groups;
             $model['default_field_values'] = $settings->default_field_values;
         }
         $model['organization_information'][0] = $organizationInfo;
         $model['admin_information'][0] = $organizationInfo['users'][0];
     }
     $form = $formBuilder->create('App\\SuperAdmin\\Forms\\Organization', ['method' => isset($organizationInfo) ? 'PUT' : 'POST', 'url' => isset($organizationInfo) ? route('admin.edit-organization', [$orgId]) : route('admin.add-organization'), 'model' => $model]);
     return view('superAdmin.addOrganization', compact('form', 'orgId'));
 }
예제 #27
0
 /**
  * Gets existing instance or create a new search input form.
  *
  * @param string $action Form action URL
  * @return Form
  */
 public static function getSearchForm($action = '')
 {
     $class = get_called_class();
     if (empty(self::$searchForms[$class])) {
         self::$searchForms[$class] = self::$formBuilder->plain(['class' => 'form-inline', 'method' => 'get', 'url' => $action])->add('query', 'text', ['label' => false, 'attr' => ['placeholder' => self::$translator->trans('lavanda::common.search_placeholder')]])->add('search', 'submit', ['label' => self::$translator->trans('lavanda::common.search_button')]);
     }
     return self::$searchForms[$class];
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, FormBuilder $formBuilder)
 {
     $applicationRequest_arr = [];
     $applicationRequest = ApplicationRequestQuery::create()->findPK($id);
     $applicationRequest_arr = $applicationRequest->toArray();
     $form = $formBuilder->create('App\\Forms\\ApplicationRequestForm', ['method' => 'PATCH', 'action' => ['ApplicationRequestController@update', $id], 'model' => $applicationRequest_arr]);
     $form_name = 'APPLICATION_REQUEST';
     $action = 'EDIT';
     $path = $this->main_page;
     session(['attribute' => \Lang::get('general.APPLICATION_REQUEST')]);
     return view('manage', compact('form', 'form_name', 'action', 'path'));
 }
예제 #29
0
 /**
  * Display the contact page to prepare and send an email.
  *
  * @param Request $request
  * @param         $model
  * @param         $id
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function contactModel(Request $request, $model, $id)
 {
     //first get the username of the logged in user
     $username = Helper::navbarUsername();
     //determine what model to use and what data to fetch
     $data = $this->_getModelAndId($model, $id, true);
     //something went wrong, redirect
     if (!$data) {
         return redirect()->back()->with(['error' => 'This ' . $model . ' does not exist!']);
     }
     $form = $this->formBuilder->create('App\\Http\\Forms\\ContactForm', ['method' => 'POST', 'url' => route('contact.email.posted')]);
     $form->add('model', 'hidden', ['value' => $model]);
     $form->add('id', 'hidden', ['value' => $id]);
     $form->add('send', 'submit', ['label' => 'Send this message', 'attr' => ['class' => 'btn btn-primary btn-block']]);
     if (isset($request['classified'])) {
         $add = Classified::whereId($request['classified'])->first();
         $title = 'Re: ' . str_limit($add->title, 34);
         $form->modify('subject', 'text', ['default_value' => $title]);
     }
     return view('contact.contact_' . $model, compact('username', 'model', 'data', 'form'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, FormBuilder $formBuilder)
 {
     $application_arr = [];
     $application = ApplicationQuery::create()->findPK($id);
     $application_arr = $application->toArray();
     //echo "<pre>";print_r($application_arr);die;
     $form = $formBuilder->create('App\\Forms\\ApplicationForm', ['method' => 'PATCH', 'action' => ['ApplicationController@update', $id], 'model' => $application_arr]);
     $form_name = 'APPLICATION';
     $action = 'EDIT_OBJ';
     $path = $this->main_page;
     $back = $this->main_page;
     session(['attribute' => \Lang::get('general.APPLICATION_OBJ')]);
     return view('manage', compact('form', 'form_name', 'action', 'path', 'back'));
 }