public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $propertyTypeChoices = [];
     $propertyTypes = $this->_entityManager->getRepository("AppBundle:EstateType")->findSpecificType(1);
     foreach ($propertyTypes as $propertyType) {
         $propertyTypeChoices[$propertyType['stringId']] = $propertyType['title'];
     }
     foreach (Estate::getTradeTypes() as $tradeType) {
         $propertyTradeTypeChoices[$tradeType] = mb_convert_case($this->_translator->trans('state.catalog.trade_type_' . $tradeType), MB_CASE_TITLE, "UTF-8");
     }
     $builder->add("name", 'text', ['label' => "proposal.common.name.label", 'attr' => ['placeholder' => "proposal.common.name.placeholder"]])->add("phone", 'text', ['label' => "proposal.common.phone.label", 'attr' => ['placeholder' => "proposal.common.phone.placeholder"]])->add("email", 'email', ['label' => "proposal.common.email.label", 'attr' => ['placeholder' => "proposal.common.email.placeholder"]])->add("type", 'choice', ['label' => "proposal.common.type.label", 'attr' => ['placeholder' => "proposal.common.type.placeholder"], 'choices' => $propertyTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.type.valid"])->add("tradeType", 'choice', ['label' => "proposal.common.trade_type.label", 'attr' => ['placeholder' => "proposal.common.trade_type.placeholder"], 'choices' => $propertyTradeTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.trade_type.valid"])->add("priceCurrency", 'choice', ['label' => "proposal.common.price_currency.label", 'attr' => ['placeholder' => "proposal.common.price_currency.placeholder"], 'choices' => ['UAH' => "UAH", 'USD' => "USD"], 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.price_currency.valid"])->add("priceRentValue", 'number', ['required' => FALSE, 'label' => "proposal.residential.price_rent_value.label", 'attr' => ['placeholder' => "proposal.residential.price_rent_value.placeholder"], 'precision' => 2])->add("priceSaleValue", 'number', ['required' => FALSE, 'label' => "proposal.common.price_sale_value.label", 'attr' => ['placeholder' => "proposal.common.price_sale_value.placeholder"], 'precision' => 2])->add("street", "text", ['label' => "proposal.common.street.label", 'attr' => ['placeholder' => "proposal.common.street.placeholder"]])->add("house", "text", ['label' => "proposal.common.house.label", 'attr' => ['placeholder' => "proposal.common.house.placeholder"]])->add("space", "text", ['label' => "proposal.common.space.label", 'attr' => ['placeholder' => "proposal.common.space.placeholder"]])->add("spacePlot", "text", ['required' => FALSE, 'label' => "proposal.residential.space_plot.label", 'attr' => ['placeholder' => "proposal.residential.space_plot.placeholder"]])->add("roomsNumber", "number", ['label' => "proposal.residential.rooms_number.label", 'attr' => ['placeholder' => "proposal.residential.rooms_number.placeholder"]])->add("bathroomsNumber", "number", ['label' => "proposal.residential.bathrooms_number.label", 'attr' => ['placeholder' => "proposal.residential.bathrooms_number.placeholder"]])->add("bedroomsNumber", "number", ['required' => FALSE, 'label' => "proposal.residential.bedrooms_number.label", 'attr' => ['placeholder' => "proposal.residential.bedrooms_number.placeholder"]])->add("floor", "number", ['required' => FALSE, 'label' => "proposal.residential.floor.label", 'attr' => ['placeholder' => "proposal.residential.floor.placeholder"]])->add("floorsNumber", "number", ['required' => FALSE, 'label' => "proposal.residential.floors_number.label", 'attr' => ['placeholder' => "proposal.residential.floors_number.placeholder"]])->add("isCashless", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.is_cashless.label"])->add("isNewBuilding", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.is_new_building.label"])->add("hasElevator", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.has_elevator.label"])->add("hasParking", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.has_parking.label"])->add("hasFurniture", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.has_furniture.label"])->add("hasRegistration", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.has_registration.label"])->add("description", "textarea", ['required' => FALSE, 'label' => "proposal.common.description.label"])->add("wasted", "checkbox", ['label' => "proposal.common.wasted.label"])->add("send", 'submit', ['label' => "proposal.common.submit.label"]);
 }
 public function availableTradeTypes(array $estates, $flatValues = FALSE)
 {
     $availableTradeTypes = [];
     $existingTradeTypes = Estate::getTradeTypes();
     foreach ($estates as $estate) {
         if ($estate instanceof Estate) {
             if (!in_array($estate->getTradeType(), $availableTradeTypes, TRUE) && !empty($existingTradeTypes[$estate->getTradeType()])) {
                 $availableTradeTypes[$estate->getTradeType()] = $existingTradeTypes[$estate->getTradeType()];
             }
         }
     }
     return $availableTradeTypes;
 }
Beispiel #3
0
 protected function configureFormFields(FormMapper $formMapper)
 {
     $translator = $this->getConfigurationPool()->getContainer()->get("translator");
     $lTranslator = function ($input, $transDomain) use($translator) {
         $output = [];
         foreach ($input as $key => $value) {
             $output[$key] = $translator->trans($value, [], $transDomain);
         }
         return $output;
     };
     $tradeTypes = $lTranslator(Estate::getTradeTypes(), "trade_types");
     $districts = $lTranslator(Estate::getDistricts(), "districts");
     $estateTypeQuery = $this->modelManager->getEntityManager('AppBundle\\Entity\\EstateType')->createQueryBuilder()->select("estateType")->from('AppBundle\\Entity\\EstateType', 'estateType')->where("estateType.parent IS NOT NULL");
     $formMapper->with("Нерухомість - Локалізований контент")->add("translations", "a2lix_translations_gedmo", ["locales" => ['ua', 'en'], "label" => FALSE, "translatable_class" => 'AppBundle\\Entity\\Estate', "required" => TRUE, "fields" => ["title" => ["locale_options" => ["ua" => ["required" => FALSE, "label" => "Назва об'єкту"], "en" => ["required" => FALSE, "label" => "Estate title"]]], "address" => ["locale_options" => ["ua" => ["label" => "Точна адреса об'єкту"], "en" => ["required" => FALSE, "label" => "Exact property address"]]], "description" => ["locale_options" => ['ua' => ['label' => 'Опис', 'field_type' => 'ckeditor', 'config_name' => 'base_config'], 'en' => ["required" => FALSE, 'label' => 'Description', 'field_type' => 'ckeditor', 'config_name' => 'base_config']]], 'slug' => ['display' => FALSE]]])->end()->with("Нерухомість - Ручне введення координат")->add("coordinatesManualLat", "text", ['required' => FALSE, 'label' => "Широта"])->add("coordinatesManualLng", "text", ['required' => FALSE, 'label' => "Довгота"])->end()->with("Нерухомість - Загальні дані")->add("code", "text", ["label" => "ID"])->add("tradeType", "choice", ["label" => "Тип транзакції", "placeholder" => "Оберіть тип транзакції...", "choices" => $tradeTypes])->add("estateType", NULL, ["label" => "Тип нерухомості", "required" => TRUE, "placeholder" => "Оберіть тип нерухомості...", "class" => 'AppBundle\\Entity\\EstateType', "query_builder" => $estateTypeQuery], ['edit' => 'standard'])->add("district", "choice", ["label" => "Район", "placeholder" => "Оберіть район...", "choices" => $districts])->add("space", "number", ["label" => "Площа", "precision" => 2])->add("spacePlot", "number", ["required" => FALSE, "label" => "Площа ділянки", "precision" => 2])->add("priceUAH", "number", ["required" => FALSE, "label" => "Ціна (UAH)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("priceUSD", "number", ["label" => "Ціна (USD)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("pricePerSquareUAH", "number", ["required" => FALSE, "label" => "Ціна за м2 (UAH)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("pricePerSquareUSD", "number", ["required" => FALSE, "label" => "Ціна за м2 (USD)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add('isActive', 'checkbox', ["required" => FALSE, "label" => "Відображається"])->end()->with("Нерухомість - Особливості")->add('estateFeatures', 'sonata_type_admin', ['label' => FALSE, 'delete' => FALSE])->end()->with("Нерухомість - Характеристики")->add('estateAttribute', 'sonata_type_collection', ['label' => FALSE, 'by_reference' => FALSE, 'btn_add' => "Додати характеристику"], ['edit' => 'inline', 'inline' => 'table'])->end()->with("Нерухомість - Фотографії")->add('estatePhoto', 'sonata_type_collection', ['required' => TRUE, 'label' => "Керування зображеннями", 'by_reference' => FALSE, 'btn_add' => "Додати зображення"], ['edit' => 'inline', 'inline' => 'table', 'sortable' => 'position'])->end();
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $propertyTypeChoices = [];
     $propertyTypes = $this->_entityManager->getRepository("AppBundle:EstateType")->findSpecificType(2);
     foreach ($propertyTypes as $propertyType) {
         $propertyTypeChoices[$propertyType['stringId']] = $propertyType['title'];
     }
     foreach (Estate::getTradeTypes() as $tradeType) {
         $propertyTradeTypeChoices[$tradeType] = mb_convert_case($this->_translator->trans('state.catalog.trade_type_' . $tradeType), MB_CASE_TITLE, "UTF-8");
     }
     foreach (Estate::getFitOutTypes() as $fitOutType) {
         $propertyFitOutTypeChoices[$fitOutType] = mb_convert_case($this->_translator->trans('state.catalog.fit_out_type_' . $fitOutType), MB_CASE_TITLE, "UTF-8");
     }
     foreach (Estate::getLayoutTypes() as $layoutType) {
         $propertyLayoutTypeChoices[$layoutType] = mb_convert_case($this->_translator->trans('state.catalog.layout_type_' . $layoutType), MB_CASE_TITLE, "UTF-8");
     }
     $builder->add("name", 'text', ['label' => "proposal.common.name.label", 'attr' => ['placeholder' => "proposal.common.name.placeholder"]])->add("phone", 'text', ['label' => "proposal.common.phone.label", 'attr' => ['placeholder' => "proposal.common.phone.placeholder"]])->add("email", 'email', ['label' => "proposal.common.email.label", 'attr' => ['placeholder' => "proposal.common.email.placeholder"]])->add("type", 'choice', ['label' => "proposal.common.type.label", 'attr' => ['placeholder' => "proposal.common.type.placeholder"], 'choices' => $propertyTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.type.valid"])->add("tradeType", 'choice', ['label' => "proposal.common.trade_type.label", 'attr' => ['placeholder' => "proposal.common.trade_type.placeholder"], 'choices' => $propertyTradeTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.trade_type.valid"])->add("city", "text", ['label' => "proposal.common.city.label", 'attr' => ['placeholder' => "proposal.common.city.placeholder"]])->add("street", "text", ['label' => "proposal.common.street.label", 'attr' => ['placeholder' => "proposal.common.street.placeholder"]])->add("house", "text", ['label' => "proposal.common.house.label", 'attr' => ['placeholder' => "proposal.common.house.placeholder"]])->add("space", "text", ['label' => "proposal.common.space.label", 'attr' => ['placeholder' => "proposal.common.space.placeholder"]])->add("fitOutType", 'choice', ['label' => "proposal.commercial.fit_out_type.label", 'attr' => ['placeholder' => "proposal.commercial.fit_out_type.placeholder"], 'choices' => $propertyFitOutTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.commercial.fit_out_type.valid"])->add("layoutType", 'choice', ['label' => "proposal.commercial.layout_type.label", 'attr' => ['placeholder' => "proposal.commercial.layout_type.placeholder"], 'choices' => $propertyLayoutTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.commercial.layout_type.valid"])->add("priceCurrency", 'choice', ['label' => "proposal.common.price_currency.label", 'attr' => ['placeholder' => "proposal.common.price_currency.placeholder"], 'choices' => ['UAH' => "UAH", 'USD' => "USD"], 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.price_currency.valid"])->add("priceRentValue", 'number', ['required' => FALSE, 'label' => "proposal.commercial.price_rent_value.label", 'attr' => ['placeholder' => "proposal.commercial.price_rent_value.placeholder"], 'precision' => 2])->add("priceSaleValue", 'number', ['required' => FALSE, 'label' => "proposal.common.price_sale_value.label", 'attr' => ['placeholder' => "proposal.common.price_sale_value.placeholder"], 'precision' => 2])->add("operatingExpenseValue", 'number', ['required' => FALSE, 'label' => "proposal.commercial.operating_expense_value.label", 'attr' => ['placeholder' => "proposal.commercial.operating_expense_value.placeholder"], 'precision' => 2])->add("parkingBayNumber", "number", ['required' => FALSE, 'label' => "proposal.commercial.parking_bay_number.label", 'attr' => ['placeholder' => "proposal.commercial.parking_bay_number.placeholder"]])->add("parkingBayPriceValue", 'number', ['required' => FALSE, 'label' => "proposal.commercial.parking_bay_price_value.label", 'attr' => ['placeholder' => "proposal.commercial.parking_bay_price_value.placeholder"], 'precision' => 2])->add("description", "textarea", ['required' => FALSE, 'label' => "proposal.common.description.label"])->add("wasted", "checkbox", ['label' => "proposal.common.wasted.label"])->add("send", 'submit', ['label' => "proposal.common.submit.label"]);
 }
 public function validate($value, Constraint $constraint)
 {
     if (!in_array($value, Estate::getTradeTypes())) {
         $this->context->buildViolation($constraint->message)->addViolation();
     }
 }