How to implement update action for foll scenario in yii2?

I am using yii2 basic.

I have to take survey for village, where in firstly I create villagedata for particular village and then I create family survey for selected villagedata.

I have two tables villagedata and persondata. The relation is one-to-many.

villagedata contains:

  1. VillageDataId

  2. DistrictId

  3. TalukaId

  4. VillageId

  5. NoOfHouseholds

  6. TotalPopulation

  7. TotalMale

  8. TotalFemale

  9. TotalChildren

  10. Year

persondata contains:

  1. PersonId

  2. DistrictId

  3. TalukaId

  4. VillageId

  5. VillageDataId

  6. PersonNamwe

  7. FamilySize, etc.

I have two CRUD’s for villagedata and persondata

1. For VillageData, actionCreate() is as follows:

The villagedata should not be created if count==1 for selected DistrictId, TalukaId, VillageId and Year.

When count==0, then only village data should be created.

So, actionCreate() works fine


2.[/b] But for actionUpdate(), the scenario is not working

For eg: There are village data for 2 villages taken in year 2017. One for village Arangaon and other for Walki.

Now in update, if I implement the same condition as in actionCreate(), then update action is not getting worked.

How to accomplish this?

maybe you better show your code?

I have attached two files:

  1. actionCreate.txt

  2. actionUpdate.txt