Rositsa Ruseva

Rositsa Ruseva

  • 1.4k
  • 209
  • 28.4k

EditForm, input fields

Feb 27 2023 4:56 AM

I have this model:
 

public class RecipeDto
    {
        public int Id { get; set; }

        [Required(ErrorMessage = "Title is required")]
        public string Title { get; set; }

        [Required(ErrorMessage = "Description is required")]
        public string Description { get; set; }

        [Required(ErrorMessage = "Ingredients are required")]
        public List<string> Ingredients { get; set; }

        [Required(ErrorMessage = "Directions are required")]
        public List<string> Directions { get; set; }

        [Range(0, int.MaxValue, ErrorMessage = "Preparation time must be a positive number")]
        public int PreparationTimeInMinutes { get; set; }

        [Range(0, int.MaxValue, ErrorMessage = "Cooking time must be a positive number")]
        public int CookingTimeInMinutes { get; set; }

        [Range(0, 20, ErrorMessage = "Servings must be a positive number with 20 as a limit")]
        public int Servings { get; set; }

        public string ImageUrl { get; set; }

        public DateTime CreatedAt { get; set; }

        public List<CategoryDto> Categories { get; set; }
    }

I want to create a Razor component to Create a recipe. But don't know which input should I use with the properties of type List<string>.
Is it even posible or should I change the type?
On my mind it only comes to use InputText. I will appreciate any advice regarding the CreateRecipe component.


Answers (2)